-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] added a simple way to replace a service by keeping a reference to the old one #10600
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
Conversation
your PR conflicts. Can you rebase it ? |
…ing a reference to the old one
Rebased |
public function setDecoratedService($id, $renamedId = null) | ||
{ | ||
if ($renamedId && $id == $renamedId) { | ||
throw new \LogicException(sprintf('The decorated service inner name for "%s" must be different than the service name itself.', $id)); |
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.
I would use InvalidArgumentException
I've added unit test and dumpers / loaders |
* | ||
* @throws InvalidArgumentException In case the decorated service id and the new decorated service id are equals. | ||
*/ | ||
public function setDecoratedService($id, $renamedId = null) |
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.
this method currently does not allow to reset it. We should find a way to do it (maybe passing null
as id) as we will need to do it
PR updated, @stof comments addressed |
if (!$decorated = $definition->getDecoratedService()) { | ||
continue; | ||
} | ||
$definition->setDecoratedService(null); |
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.
https://github.com/symfony/symfony/pull/10600/files#r11152517 has been addressed here
…service by keeping a reference to the old one (romainneutron) This PR was merged into the 2.5-dev branch. Discussion ---------- [DependencyInjection] added a simple way to replace a service by keeping a reference to the old one | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #5920 | License | MIT | Doc PR | symfony/symfony-docs#3745 This PR replaces #9003. Here's the todo list: - [x] add a cookbook entry for this new feature - [x] add support in all loaders/dumpers - [x] add unit tests - [x] see if there are use cases in Symfony that would benefit from this new feature - [x] find the best name for this feature I've implemented YAML and XML Loader / Dumper. From what I see, PhpDumper, PhpLoader, IniLoader, GraphvizDumper do not require an update, am I wrong? Commits ------- 140f807 [DependencyInjection] Update dumpers and loaders, add unit tests 1eb1f4d [DependencyInjection] added a simple way to replace a service by keeping a reference to the old one
…ecoration (romainneutron) This PR was submitted for the master branch but it was merged into the 2.5 branch instead (closes #3753). Discussion ---------- [DependencyInjection] Add documentation about service decoration | Q | A | ------------- | --- | Doc fix? | yes | New docs? | yes (symfony/symfony#10600) | Applies to | 2.5+ | Fixed tickets | #3745 Commits ------- 578d2e2 [DependencyInjection] Add documentation about service decoration
This PR replaces #9003. Here's the todo list:
I've implemented YAML and XML Loader / Dumper.
From what I see, PhpDumper, PhpLoader, IniLoader, GraphvizDumper do not require an update, am I wrong?