Problem/Motivation

Since #3311365: Use PHP attributes for route discovery has introduced route definitions via PHP attributes, this means route discovery iterates through and reflects all files/classes in the Controller namespace/directory of modules.

There are some controllers that are not in a Controller namespace / directory so they can't use Route attributes.

Steps to reproduce

Runtime:

grep -rn '_controller:' core --include="*.routing.yml" \
  | grep -v '\\Drupal\\[a-zA-Z_]*\\Controller\\' \
  | grep -v tests

Tests:

grep -rn '_controller:' core --include="*.routing.yml" \
  | grep -v '\\Drupal\\[a-zA-Z_]*\\Controller\\' \
  | grep tests

Results attached

Proposed resolution

Move some or all of these to a Controller subdirectory.

Co-ordinate with #3490484: [meta] Lots of non-plugin PHP classes in plugin directories and #3584795: Remove non-controller classes from module Controller namespaces/folders to avoid conflicts.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
controllers-test.txt28.03 KBmstrelan
controllers-runtime.txt2.36 KBmstrelan

Comments

mstrelan created an issue.

catch’s picture

Would we not do this as part of #3584794: Convert core routes to PHP attributes? Or should it be done in one MR for all of the classes as a prerequisite to those issues maybe?

mstrelan’s picture

I thought as a prerequisite would make reviewing the conversions easier. Not sure how noisy the deprecation for these is. Saw moved_classes mentioned but I don't actually know what that is.

catch’s picture

Oh that is #3509577: Classloader with support for moving/deprecating classes / #3502882: Add a classloader that can handle class moves it was added for the related plugins issue (but the plugins didn't get moved yet so only one or two usages in core so far).

Prerequisite probably makes sense yeah, should mean no diff at all in the moved files except the namespace.