diff --git a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php index 3f637ecd..61e49f23 100644 --- a/core/modules/menu_link_content/src/Entity/MenuLinkContent.php +++ b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php @@ -10,6 +10,7 @@ use Drupal\Core\Field\BaseFieldDefinition; use Drupal\link\LinkItemInterface; use Drupal\menu_link_content\MenuLinkContentInterface; +use Drupal\system\MenuInterface; /** * Defines the menu link content entity class. @@ -74,6 +75,14 @@ public function setInsidePlugin() { $this->insidePlugin = TRUE; } + /** + * {@inheritdoc} + */ + public function setMenu(MenuInterface $menu) { + $this->set('menu', $menu->id()); + return $this; + } + /** * {@inheritdoc} */ @@ -95,6 +104,13 @@ public function getMenuName() { return $this->get('menu_name')->value; } + /** + * {@inheritdoc} + */ + public function getMenu() { + return $this->get('menu')->entity; + } + /** * {@inheritdoc} */ @@ -310,6 +326,10 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setDefaultValue('tools') ->setSetting('is_ascii', TRUE); + $fields['menu'] = BaseFieldDefinition::create('entity_reference') + ->setLabel(t('Menu')) + ->setDescription(t('The menu this link is part of.')); + $fields['link'] = BaseFieldDefinition::create('link') ->setLabel(t('Link')) ->setDescription(t('The location this menu link points to.')) diff --git a/core/modules/menu_link_content/src/MenuLinkContentInterface.php b/core/modules/menu_link_content/src/MenuLinkContentInterface.php index 1d01522d..371eaa90 100644 --- a/core/modules/menu_link_content/src/MenuLinkContentInterface.php +++ b/core/modules/menu_link_content/src/MenuLinkContentInterface.php @@ -5,6 +5,7 @@ use Drupal\Core\Entity\EntityChangedInterface; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityPublishedInterface; +use Drupal\system\MenuInterface; /** * Defines an interface for custom menu links. @@ -16,6 +17,16 @@ */ public function setInsidePlugin(); + /** + * Sets the menu entity of the custom menu link. + * + * @param \Drupal\system\MenuInterface $menu + * The menu entity. + * + * @return $this + */ + public function setMenu(MenuInterface $menu); + /** * Gets the title of the menu link. * @@ -40,6 +51,14 @@ public function getUrlObject(); */ public function getMenuName(); + /** + * Gets the menu entity of the custom menu link. + * + * @return \Drupal\system\MenuInterface + * The menu entity. + */ + public function getMenu(); + /** * Gets the description of the menu link for the UI. * diff --git a/menu-name-is-a-string-field-2984224-4.patch b/menu-name-is-a-string-field-2984224-4.patch index 40a03367..e69de29b 100644 --- a/menu-name-is-a-string-field-2984224-4.patch +++ b/menu-name-is-a-string-field-2984224-4.patch @@ -1,6 +0,0 @@ -diff --git a/web/core b/web/core ---- a/web/core -+++ b/web/core -@@ -1 +1 @@ --Subproject commit b5f629af842186b7bbfb20fe60f32858cbaa35fe -+Subproject commit b5f629af842186b7bbfb20fe60f32858cbaa35fe-dirty