API page: https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!menu.api.php...

I'm seeing the following items in the menu items which aren't documented:

- load arguments
- id
- metadata
- class
- form_class
- deriver
- provider

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

joachim created an issue. See original summary.

Vinay15’s picture

Assigned: Unassigned » Vinay15
Vinay15’s picture

Hi Joachim,

Can you suggest me some things, I am not sure about these.

- load arguments: is this same as drupal 7 load arguments parameter in hook_menu()?
- id: is this the machine name of the menu link?
- metadata: can this be simply saying "metadata about the menu link" ?
- class: is it MenuLinkDefaultForm ?

No guesses for the others.

joachim’s picture

I'm not sure myself on most of these.

It looks like class and form class set the plugin class to be used for rendering the menu link, and for producing the menu link edit form respectively. In both cases, these are fully qualified class names.

joachim’s picture

> route_name: (optional) The route name to be used to build the path. Either the route_name or url element must be provided.

Also, that isn't true.

The user.logout link has neither.

joachim’s picture

Also, this hook has no return -- &$links is to be altered in place.

jhodgdon’s picture

This hook documentation is wrong in other ways... for instance, there is no return value. It's an alter hook, so you should modify the $links in place.

So, regarding the properties...

This is the method that actually gets the definitions that are passed into this hook:

https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Plugin!Discovery!...

So what is in there is whatever is in the YAML files that define the menu links, plus 'provider' and 'id'.

For documentation on what is supposed to be in menu links YAML, we have
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!menu.api.php...
and pages on drupal.org that it links to.

So, look there....

Vinay15’s picture

So, should I remove @return from this hook and paste all the description in @return above @param?
Because the description is quite helpful to the reader.

joachim’s picture

You're right that we shouldn't lose the description from the @return, but it should move into the @param $links, because it tells you what you'll find in $links.

Vinay15’s picture

Status: Active » Needs review
FileSize
794 bytes

I have removed the return doc and added the description to @param description.

jhodgdon’s picture

Status: Needs review » Needs work

Thanks! Yes, that is the correct fix for the @param/@return sections. However, the patch doesn't address the problem in the issue summary yet (the missing properties).

Vinay15’s picture

Assigned: Vinay15 » Unassigned
ashishdalvi’s picture

Assigned: Unassigned » ashishdalvi

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

nikunjkotecha’s picture

Assigned: ashishdalvi » nikunjkotecha
Issue tags: +#dcdelhi
nikunjkotecha’s picture

Assigned: nikunjkotecha » Unassigned
Issue tags: -#dcdelhi

not good at documentation

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.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.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.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.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.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.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.

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.

Rithesh BK’s picture

Assigned: Unassigned » Rithesh BK

currently i am working on it ....

Rithesh BK’s picture

let me go through the documentation ....

Rithesh BK’s picture

Assigned: Rithesh BK » Unassigned
Status: Needs work » Fixed

@Vinay15 As the patch mentioned in the #10 is good to go as the documentation says that the links will be altered based on the function which is mentioned below

function hook_menu_links_discovered_alter(&$links) {

  // Change the weight and title of the user.logout link.
  $links['user.logout']['weight'] = -10;
  $links['user.logout']['title'] = new \Drupal\Core\StringTranslation\TranslatableMarkup('Logout');

  // Conditionally add an additional link with a title that's not translated.
  if (\Drupal::moduleHandler()
    ->moduleExists('search')) {
    $links['menu.api.search'] = array(
      'title' => \Drupal::config('system.site')
        ->get('name'),
      'route_name' => 'menu.api.search',
      'description' => new \Drupal\Core\StringTranslation\TranslatableMarkup('View popular search phrases for this site.'),
      'parent' => 'system.admin_reports',
    );
  }
}
Rithesh BK’s picture

Status: Fixed » Needs review

@Vinay15 As the patch mentioned in the #10 is good to go as the documentation says that the links will be altered based on the function which is mentioned below

function hook_menu_links_discovered_alter(&$links) {

  // Change the weight and title of the user.logout link.
  $links['user.logout']['weight'] = -10;
  $links['user.logout']['title'] = new \Drupal\Core\StringTranslation\TranslatableMarkup('Logout');

  // Conditionally add an additional link with a title that's not translated.
  if (\Drupal::moduleHandler()
    ->moduleExists('search')) {
    $links['menu.api.search'] = array(
      'title' => \Drupal::config('system.site')
        ->get('name'),
      'route_name' => 'menu.api.search',
      'description' => new \Drupal\Core\StringTranslation\TranslatableMarkup('View popular search phrases for this site.'),
      'parent' => 'system.admin_reports',
    );
  }
}

joachim’s picture

Status: Needs review » Needs work

Based on #11, this is still needing work.

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.

saurabh-2k17’s picture

Assigned: Unassigned » saurabh-2k17

Hi @joachim i tried adding the items name but i am not able to describe them (only that they are optional). A small description for each would be helpful to update the patch and close this issue.Thanks

saurabh-2k17’s picture

Assigned: saurabh-2k17 » Unassigned

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.

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

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.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.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.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, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.