Skip to content

[DependencyInjection] Add a remove() method to the PHP configurator #39806

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

Merged
merged 1 commit into from
Jan 19, 2021

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Jan 12, 2021

Q A
Branch? 5.x
Bug fix? no
New feature? no
Deprecations? no
License MIT
Doc PR todo

This especially useful in the configureContainer() method of the kernel. It allows to not use a compiler pass to remove some services (for instance, in test mode).

@@ -58,6 +59,11 @@ public function __construct(ContainerBuilder $container, array $instanceof, bool

public function __destruct()
{
if ($this->destructed) {
Copy link
Member Author

@dunglas dunglas Jan 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This trick prevents the destructor to re-add a service when it has been removed just after being added (see tests).

@dunglas dunglas force-pushed the feat/di-php-config-remove branch from c9e8318 to 0540c6f Compare January 13, 2021 21:41
@nicolas-grekas nicolas-grekas force-pushed the feat/di-php-config-remove branch from 0540c6f to dcf75fa Compare January 19, 2021 11:06
@nicolas-grekas
Copy link
Member

Thank you @dunglas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants