diff --git a/core/modules/menu_link/src/Plugin/Menu/MenuLinkField.php b/core/modules/menu_link/src/Plugin/Menu/MenuLinkField.php index e39e1f9..7b88497 100644 --- a/core/modules/menu_link/src/Plugin/Menu/MenuLinkField.php +++ b/core/modules/menu_link/src/Plugin/Menu/MenuLinkField.php @@ -8,6 +8,7 @@ namespace Drupal\menu_link\Plugin\Menu; use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Menu\MenuLinkBase; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; @@ -80,8 +81,15 @@ public function getTitle() { // We only need to get the title from the actual entity if it may be a // translation based on the current language context. This can only happen // if the site is configured to be multilingual. - if (!empty($this->pluginDefinition['metadata']['translateable']) && $this->languageManager->isMultilingual()) { - return $this->getEntity()->getTitle(); + if (!empty($this->pluginDefinition['metadata']['translatable']) && $this->languageManager->isMultilingual()) { + /** @var \Drupal\Core\TypedData\TranslatableInterface|\Drupal\Core\Entity\EntityInterface $entity */ + $entity = $this->getEntity(); + $entity = $entity->getTranslation($this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId()); + $field_name = $this->getMetaData()['field_name']; + if ($title = $entity->$field_name->title) { + return $title; + } + return $entity->label(); } return $this->pluginDefinition['title']; } diff --git a/core/profiles/standard/config/install/core.entity_form_display.node.page.default.yml b/core/profiles/standard/config/install/core.entity_form_display.node.page.default.yml index 32ffd5b..c7e9ff1 100644 --- a/core/profiles/standard/config/install/core.entity_form_display.node.page.default.yml +++ b/core/profiles/standard/config/install/core.entity_form_display.node.page.default.yml @@ -3,11 +3,13 @@ status: true dependencies: config: - field.field.node.page.body + - field.field.node.page.field_menu - node.type.page module: - entity_reference - path - text + - menu_link id: node.page.default targetEntityType: node bundle: page @@ -59,5 +61,10 @@ content: summary_rows: 3 placeholder: '' third_party_settings: { } + field_menu: + weight: 32 + settings: { } + third_party_settings: { } + type: menu_link_default hidden: { } third_party_settings: { } diff --git a/core/profiles/standard/config/install/field.field.node.page.field_menu.yml b/core/profiles/standard/config/install/field.field.node.page.field_menu.yml new file mode 100644 index 0000000..a1caa3e --- /dev/null +++ b/core/profiles/standard/config/install/field.field.node.page.field_menu.yml @@ -0,0 +1,24 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_menu + - node.type.page + module: + - menu_link +id: node.page.field_menu +field_name: field_menu +entity_type: node +bundle: page +label: menuliank +description: '' +required: false +translatable: true +default_value: { } +default_value_callback: '' +settings: + available_menus: + - main + parent: 'main:' +third_party_settings: { } +field_type: menu_link diff --git a/core/profiles/standard/config/install/field.storage.node.field_menu.yml b/core/profiles/standard/config/install/field.storage.node.field_menu.yml new file mode 100644 index 0000000..cb69efc --- /dev/null +++ b/core/profiles/standard/config/install/field.storage.node.field_menu.yml @@ -0,0 +1,17 @@ +langcode: en +status: true +dependencies: + module: + - menu_link + - node +id: node.field_menu +field_name: field_menu +entity_type: node +type: menu_link +settings: { } +module: menu_link +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false diff --git a/core/profiles/standard/src/Tests/StandardTest.php b/core/profiles/standard/src/Tests/StandardTest.php index f8d4999..febd1c1 100644 --- a/core/profiles/standard/src/Tests/StandardTest.php +++ b/core/profiles/standard/src/Tests/StandardTest.php @@ -36,6 +36,9 @@ function testStandard() { 'administer blocks', 'post comments', 'skip comment approval', + 'bypass node access', + 'administer nodes', + 'administer menu', )); $this->drupalLogin($admin); // Configure the block. @@ -90,6 +93,16 @@ function testStandard() { $this->assertText('Foobar'); $this->assertNoText('Then she picked out two somebodies, Sally and me'); + // Ensure that the field_menu link got created. + $node = $this->drupalCreateNode(array( + 'type' => 'page', + 'title' => 'Foobar', + 'promote' => 1, + 'status' => 1, + )); + $this->drupalGet("node/{$node->id()}/edit"); + $this->assertFieldById('edit-field-menu-0-enabled', FALSE); + // Ensure block body exists. $this->drupalGet('block/add'); $this->assertFieldByName('body[0][value]'); diff --git a/core/profiles/standard/standard.info.yml b/core/profiles/standard/standard.info.yml index a1c07b2..30274e9 100644 --- a/core/profiles/standard/standard.info.yml +++ b/core/profiles/standard/standard.info.yml @@ -15,6 +15,7 @@ dependencies: - contextual - contact - menu_link_content + - menu_link - datetime - block_content - quickedit