Add MenuLinkInterface::getAdminLabel()

Created on 15 September 2015, about 9 years ago
Updated 30 September 2024, 18 days ago

Problem/Motivation

We currently have hard-coded hacks like this in MenuForm:

        elseif (($url = $link->getUrlObject()) && $url->isRouted() && $url->getRouteName() == 'user.page') {
          $form[$id]['title']['#suffix'] = ' (' . $this->t('logged in users only') . ')';
        }

This means contrib/custom menu links aren't able to do this without some heaving form altering.

See #2503755-86: Switch from user login block to login menu link and search block in standard profile โ†’ and #2503755-87: Switch from user login block to login menu link and search block in standard profile โ†’ .2.

Proposed resolution

Allow menu link plugins to specify admin labels.

Remaining tasks

TBD

User interface changes

None.

API changes

API addition.

Data model changes

None.

๐Ÿ“Œ Task
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Menu systemย  โ†’

Last updated about 21 hours ago

Created by

๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia Nikhil_110

    Attached patch against Drupal 10.1.x
    Patch #15 is not applied for Drupal 10.1.x so Inter-diff file is not added.

    Checking patch core/modules/menu_ui/src/MenuForm.php...
    Hunk #1 succeeded at 234 (offset 14 lines).
    error: while searching for:
          ]),
        ]);
        $links = $this->buildOverviewTreeForm($tree, $delta);
        foreach (Element::children($links) as $id) {
          if (isset($links[$id]['#item'])) {
            $element = $links[$id];
    
    error: patch failed: core/modules/menu_ui/src/MenuForm.php:273
    error: core/modules/menu_ui/src/MenuForm.php: patch does not apply
    Checking patch core/modules/user/src/Plugin/Menu/LoginLogoutMenuLink.php...
    Checking patch core/modules/user/src/Plugin/Menu/UserPageMenuLink.php...
    Checking patch core/modules/user/tests/src/Functional/UserAccountLinksTest.php...
    error: while searching for:
        // auto-increment is 1. Use XPath to obtain input element id and name using
        // the consistent label text.
        $this->drupalGet('admin/structure/menu/manage/account');
        $label = $this->xpath('//label[contains(.,:text)]/@for', [':text' => 'Enable My account menu link']);
        $this->assertFieldChecked($label[0]->getText(), "The 'My account' link is enabled by default.");
    
        // Disable the 'My account' link.
    
    error: patch failed: core/modules/user/tests/src/Functional/UserAccountLinksTest.php:88
    error: core/modules/user/tests/src/Functional/UserAccountLinksTest.php: patch does not apply
  • last update over 1 year ago
    29,361 pass
  • First commit to issue fork.
  • First commit to issue fork.
  • @mrinalini9 opened merge request.
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia mrinalini9 New Delhi

    Created MR for the patch changes in #27 for the 11.x branch, please review it.

    Thanks!

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    @mrinalini9 please donโ€™t take patches and just turn to MRs without checking.

    fix should use constructor promotion and type hints for and thatโ€™s just from 5 second glance.

    Also please read the comments and tags. This was tagged for issue summary which still hasnโ€™t happened

    Thanks

Production build 0.71.5 2024