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
configure Swiftmailer handlers transports depending on the current conta... #66
Conversation
{ | ||
$definitions = $container->getDefinitions(); | ||
|
||
foreach ($definitions as $id => &$definition) { |
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.
no need to use a reference here
- it is an object, so it will already be modified in place
- using a reference will force PHP to copy the reference to the array of definitions here, as you cannot share the same zval between non-reference variables (in the container builder) and reference variables.
Using references just to try being smarter than PHP at handling memory often ends up being worse.
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.
You're right of course. Don't know why I did this.
Would it work with multiple configured mailers? |
Yes, it should. |
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
foreach ($container->getDefinitions() as $id => $definition) { |
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.
Maybe if the extensoin would set a parameter with the swiftmailer handler ids in the container we could just read it out here, delete it, and loop over thoes ids instead of looping over everything. That sounds faster and more robust too.
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.
Thanks for the feedback, @Seldaek. Your suggestion sounds reasonable. I think I can get my hands back on this next weekend.
…ntainer configuration
@Seldaek I updated the implementation and added tests for the compiler pass. |
Thanks, looks good now as far as I understand the problem. |
configure Swiftmailer handlers transports depending on the current conta...
...iner configuration
This should fix #65. As you can't determine reliably inside the DI extension whether or not a container alias does exist, I added a compiler pass that does this work.