5 * Install, update and uninstall functions for the menu_link_content module.
9 * Implements hook_install().
11 function menu_link_content_install() {
12 // Add a higher weight so that menu_link_content_path_update() is called after
13 // system_path_update() clears the path alias cache.
14 // @todo remove this when the cache clearing is moved to path module or if
15 // caching is removed for path aliases due to
16 // https://www.drupal.org/node/1965074
17 module_set_weight('menu_link_content', 1);
21 * Add the publishing status entity key to custom menu links.
23 function menu_link_content_update_8601() {
24 $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
25 $entity_type = $definition_update_manager->getEntityType('menu_link_content');
27 // Add the published entity key to the menu_link_content entity type.
28 $entity_keys = $entity_type->getKeys();
29 $entity_keys['published'] = 'enabled';
30 $entity_type->set('entity_keys', $entity_keys);
31 $definition_update_manager->updateEntityType($entity_type);
33 // @todo The above should be enough, since that is the only definition that
34 // changed. But \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema varies
35 // field schema by whether a field is an entity key, so invoke
36 // EntityDefinitionUpdateManagerInterface::updateFieldStorageDefinition()
37 // with an unmodified field storage definition to trigger the necessary
38 // changes. SqlContentEntityStorageSchema::onEntityTypeUpdate() should be
39 // fixed to automatically handle this.
40 // @see https://www.drupal.org/node/2554245
41 $definition_update_manager->updateFieldStorageDefinition($definition_update_manager->getFieldStorageDefinition('enabled', 'menu_link_content'));
43 return t('The publishing status entity key has been added to custom menu links.');