-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Add autowiring capabilities #15613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
9828da2
195f6c0
8d23c9d
27f4de8
5575ec1
edce23d
07d475e
afe009a
7ab5b08
a7ca3f2
57c494c
e642aa8
d00c7e3
55bb42c
7806487
585616d
c717c69
3b7f553
936a16a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,8 @@ | |
*/ | ||
class AutowiringPass implements CompilerPassInterface | ||
{ | ||
const NO_AUTOWIRING = 'no_autowiring'; | ||
|
||
private $container; | ||
private $reflectionClasses = array(); | ||
private $definedTypes = array(); | ||
|
@@ -36,7 +38,9 @@ public function process(ContainerBuilder $container) | |
{ | ||
$this->container = $container; | ||
foreach ($container->getDefinitions() as $id => $definition) { | ||
$this->completeDefinition($id, $definition); | ||
if (!$definition->hasTag(self::NO_AUTOWIRING)) { | ||
$this->completeDefinition($id, $definition); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please reset all the internal state at the end of the method to release memory (many things are not needed at all anymore, and there is no reason to kep a circular reference between the ContainerBuilder and this pass) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why aren't you using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, I'll take a look at that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because I need the definition instance and not the tags. |
||
|
||
// Free memory and remove circular reference to container | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why storing the container? Can't you just pass it explicitly to your private methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this class already has a lot of states, it's just to avoid passing the container as argument of other methods.
I can rewrite this class without states but not sure it has any interest (and other passes also have states).