Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / rest_resource_alter.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/hook/rest_resource_alter.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/rest_resource_alter.twig
new file mode 100644 (file)
index 0000000..6c4f3f7
--- /dev/null
@@ -0,0 +1,14 @@
+/**
+ * Implements hook_rest_resource_alter().
+ */
+function {{ machine_name }}_rest_resource_alter(&$definitions) {
+  if (isset($definitions['entity:node'])) {
+    // We want to handle REST requests regarding nodes with our own plugin
+    // class.
+    $definitions['entity:node']['class'] = 'Drupal\mymodule\Plugin\rest\resource\NodeResource';
+    // Serialized nodes should be expanded to my specific node class.
+    $definitions['entity:node']['serialization_class'] = 'Drupal\mymodule\Entity\MyNode';
+  }
+  // We don't want Views to show up in the array of plugins at all.
+  unset($definitions['entity:view']);
+}