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. Removing files and classes that are not controllers from these folders can improve the speed and memory usage of the discovery.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

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

Comments

godotislate created an issue. See original summary.

mstrelan’s picture

StatusFileSize
new2.36 KB
new28.03 KB

Should we also move controllers not in a Controller namespace? These can't use Route attributes. I found 175 instances in tests and 21 outside of tests.

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.

aaronmchale’s picture

I think it would be really good to establish a convention here, it's so often the case that the src directory of a module looks a bit messy.

catch’s picture

#3490484: [meta] Lots of non-plugin PHP classes in plugin directories is very closely related and if we use moved_classes for both there could potentially be a lot of conflicts.

Maybe we could combine the scope? So move non-plugin and non-controller classes per group of modules at the same time?

godotislate’s picture

#4 sounds good. Offhand it seems like most of the work would be agreeing on a plan on where to move what types of files.

There is the instanceof issue using moved_classes/class aliases, but that can be discussed there as well.

godotislate’s picture

Re #2: I think it makes sense to open another issue to see which (non-form) controllers that aren't in the Controller namespace we want to move so that we can convert those routes to attributes.

mstrelan’s picture