X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fmenu_link_content%2Fmenu_link_content.install;fp=web%2Fcore%2Fmodules%2Fmenu_link_content%2Fmenu_link_content.install;h=8a04d028599ef379103757b76252f651c53ca59a;hp=43c75ec0fe84c461eba595de2209ad6d0ae29835;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/modules/menu_link_content/menu_link_content.install b/web/core/modules/menu_link_content/menu_link_content.install index 43c75ec0f..8a04d0285 100644 --- a/web/core/modules/menu_link_content/menu_link_content.install +++ b/web/core/modules/menu_link_content/menu_link_content.install @@ -16,3 +16,29 @@ function menu_link_content_install() { // https://www.drupal.org/node/1965074 module_set_weight('menu_link_content', 1); } + +/** + * Add the publishing status entity key to custom menu links. + */ +function menu_link_content_update_8601() { + $definition_update_manager = \Drupal::entityDefinitionUpdateManager(); + $entity_type = $definition_update_manager->getEntityType('menu_link_content'); + + // Add the published entity key to the menu_link_content entity type. + $entity_keys = $entity_type->getKeys(); + $entity_keys['published'] = 'enabled'; + $entity_type->set('entity_keys', $entity_keys); + $definition_update_manager->updateEntityType($entity_type); + + // @todo The above should be enough, since that is the only definition that + // changed. But \Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema varies + // field schema by whether a field is an entity key, so invoke + // EntityDefinitionUpdateManagerInterface::updateFieldStorageDefinition() + // with an unmodified field storage definition to trigger the necessary + // changes. SqlContentEntityStorageSchema::onEntityTypeUpdate() should be + // fixed to automatically handle this. + // @see https://www.drupal.org/node/2554245 + $definition_update_manager->updateFieldStorageDefinition($definition_update_manager->getFieldStorageDefinition('enabled', 'menu_link_content')); + + return t('The publishing status entity key has been added to custom menu links.'); +}