Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / menu_link_update.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d7/hook/menu_link_update.twig b/vendor/chi-teck/drupal-code-generator/templates/d7/hook/menu_link_update.twig
new file mode 100644 (file)
index 0000000..765056a
--- /dev/null
@@ -0,0 +1,13 @@
+/**
+ * Implements hook_menu_link_update().
+ */
+function {{ machine_name }}_menu_link_update($link) {
+  // If the parent menu has changed, update our record.
+  $menu_name = db_query("SELECT menu_name FROM {menu_example} WHERE mlid = :mlid", array(':mlid' => $link['mlid']))->fetchField();
+  if ($menu_name != $link['menu_name']) {
+    db_update('menu_example')
+      ->fields(array('menu_name' => $link['menu_name']))
+      ->condition('mlid', $link['mlid'])
+      ->execute();
+  }
+}