Problem/Motivation

First reported in #2977669: Spec Compliance: some entity types have an "id", "type" or "uuid" field, this violates the spec.

This makes it impossible to expose the relationship between MenuLinkContent and Menu entities:

    $fields['menu_name'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Menu name'))
      ->setDescription(t('The menu name. All links with the same menu name (such as "tools") are part of the same menu.'))
      ->setDefaultValue('tools')
      ->setSetting('is_ascii', TRUE);

Proposed resolution

    $fields['menu'] = BaseFieldDefinition::create('entity_reference')
      ->setLabel(t('Menu'))
      ->setDescription(t('The menu this link is part of.');

Remaining tasks

TBD

User interface changes

TBd

API changes

TBD

Data model changes

Yes!

Comments

Wim Leers created an issue. See original summary.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

bn_code’s picture

Issue tags: +epam-contrib-2019.03
bn_code’s picture

Has been added.

bn_code’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: menu-name-is-a-string-field-2984224-4.patch, failed testing. View results

bn_code’s picture

rodman1980’s picture

Issue tags: -epam-contrib-2019.03

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

mrinalini9’s picture

Assigned: Unassigned » mrinalini9
Issue tags: +Needs reroll
mrinalini9’s picture

mrinalini9’s picture

Hi,

Here is the rerolled patch.

Thanks
Mrinalini

bunty badgujar’s picture

We need to add hook_update_N to install new FieldStorageDefinition in #14.

Lal_’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 15: menu-name-is-a-string-field-2984224-15.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mrinalini9’s picture

Assigned: mrinalini9 » Unassigned
bunty badgujar’s picture

Status: Needs work » Needs review
StatusFileSize
new6.26 KB

Re-rolling #15 with test case issue fix.

Status: Needs review » Needs work

The last submitted patch, 19: menu-name-is-a-string-field-2984224-19.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

raunak.singh’s picture

Assigned: Unassigned » raunak.singh

I will create the patch passing the test cases.

raunak.singh’s picture

Assigned: raunak.singh » Unassigned
Status: Needs work » Needs review
StatusFileSize
new6.29 KB
new971 bytes

Re-rolling #19 with test case issue fix.

Status: Needs review » Needs work

The last submitted patch, 22: menu-name-is-a-string-field-2984224-22.patch, failed testing. View results

sharma.amitt16’s picture

StatusFileSize
new69.25 KB
+++ b/core/modules/menu_link_content/src/Entity/MenuLinkContent.php
@@ -80,6 +81,14 @@ public function setInsidePlugin() {
+    $this->set('menu', $menu->id());

We are adding a new column menu in the menu_link_content table while the menu_name is already there for the same purpose. This is a redundancy.

Also, the description given for the field is a little bit confusing.

menu_link_content

Shouldn't we modify the existing field or remove the existing if we are trying to use a new one.

Test cases are getting failed because we are adding a reference field but not passing the value of this in test cases. We should pass the menu in test cases.

In core/modules/menu_link_content/tests/src/Kernel/MenuLinksTest.php


public function testPendingRevisions() {
    /** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
    $storage = \Drupal::entityTypeManager()->getStorage('menu_link_content');

    // Add new menu items in a hierarchy.
    $default_root_1_title = $this->randomMachineName(8);
    $root_1 = $storage->create([
      'title' => $default_root_1_title,
      'link' => [['uri' => 'internal:/#root_1']],
      'menu_name' => 'menu_test', <strong> // We should add a new entry for menu here.</strong>
    ]);

The existing menu_name field may be used in some other places as well as in core and contributed both. So we can't remove the field directly. We need to have a plan to use/remove this.

rajandro’s picture

Issue tags: -Needs reroll
StatusFileSize
new156.69 KB

Removing Needs reroll tag as patch #22 (menu-name-is-a-string-field-2984224-22.patch) is working fine with the current core version.
9.1.x-dev

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Version: 9.4.x-dev » 10.0.x-dev
Category: Bug report » Task
Issue tags: +Bug Smash Initiative, +Needs issue summary update

Discussed in #bugsmash with larowlan. I agree with him that this is not bug and is either a task or feature request. I think task is a better fit and keeping at major.

Version: 10.0.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.