function menu_link_content_update_8601
Add the publishing status entity key to custom menu links.
File
-
core/
modules/ menu_link_content/ menu_link_content.install, line 45
Code
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.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.