Added automatically wiring dependencies if ContainerInjectionInterface is not implemented.
Closes #3409787
Merge request reports
Activity
added 111 commits
-
45b2670a...ef985e93 - 110 commits from branch
project:11.x
- da919bad - Merge branch drupal:11.x into 3409787-add-support-for
-
45b2670a...ef985e93 - 110 commits from branch
27 29 if (is_subclass_of($definition, 'Drupal\Core\DependencyInjection\ContainerInjectionInterface')) { 28 30 $instance = $definition::create($this->container); 29 31 } 32 elseif (method_exists($definition, '__construct')) { 33 $constructor = new \ReflectionMethod($definition, '__construct'); Given that this is largely a copy of AutowireTrait, can we just use AutowireTrait directly in this class (perhaps by refactoring it a bit if we need to), instead of copy-pasting?
There are existing bugs like https://www.drupal.org/project/drupal/issues/3410222 so when we fix similar issues it would be good to do it in one place only.
Yes, I agree that this should be implemented in one place but the trait seems like a bad solution. What if we mark AutowireTrait as deprecated?
Also using a trait will cause more problems if we need to implement a static cache (I did a small benchmark: using reflection is about half as slow).
can we just use AutowireTrait directly in this class (perhaps by refactoring it a bit if we need to)
I think it's not difficult, but over time I would prefer to remove the trait.
changed this line in version 8 of the diff
added 272 commits
-
3b547041...56bf8c1f - 270 commits from branch
project:11.x
- f1191b0c - Merge branch '11.x' into 3409787-add-support-for
- c3d8c787 - Fix
-
3b547041...56bf8c1f - 270 commits from branch