Problem/Motivation

Follow up from #3311365-94: Use PHP attributes for route discovery:

Route names are used to define menu links, menu tabs and at various other places also, I think we are aiming to generate auto route names but it also kind of relates to above point, How we are going to address that?

Once we've added this feature I think we could also add attributes in place of module.links.*.yml?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3584798

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

godotislate created an issue. See original summary.

longwave made their first commit to this issue’s fork.

longwave’s picture

Status: Active » Needs review

First pass, incorporating #3582628: Add a generic way of scanning classes for attributes. SystemController has a *lot* of attributes now, which seems a bit weird, but it's the most complex case by far.

longwave’s picture

One thing I should explicitly call out: in most cases the menu link title is the same as the default route title, so we take title from the route's defaults._title property if the menu link didn't explicitly set one.

I do wonder if we should somehow promote defaults._title to a top level property on the Route attribute, as it would make it all a lot easier to read.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

aaronmchale’s picture

I do wonder if we should somehow promote defaults._title to a top level property on the Route attribute, as it would make it all a lot easier to read.

Yes! If only because now that routes can be defined via attributes, the more things that are top-level keys the more we benefit from those things being discoverable by IDEs, etc. And title is probably one of the most common keys to be defined in a route.

godotislate’s picture

I think we'd need our own Route attribute to do that?

aaronmchale’s picture

I think we'd need our own Route attribute to do that?

Oh yeah that's a really good point

longwave’s picture

Could we extend the Symfony one and juggle the parameters in the constructor?

godotislate’s picture

Yes, that should be pretty easy to do. In that case, we probably want to consider other top level properties we want, if any, and add them all at once. That way we reduce the need of introducing new ones later and potentially causing confusion/fatal errors on missing named parameters.

godotislate’s picture