Skip to content

[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

Merged
merged 2 commits into from
Apr 1, 2014

Conversation

romainneutron
Copy link
Contributor

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:

  • add a cookbook entry for this new feature
  • add support in all loaders/dumpers
  • add unit tests
  • see if there are use cases in Symfony that would benefit from this new feature
  • 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?

@stof
Copy link
Member

stof commented Mar 31, 2014

your PR conflicts. Can you rebase it ?

@romainneutron
Copy link
Contributor Author

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));
Copy link
Member

Choose a reason for hiding this comment

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

I would use InvalidArgumentException

@romainneutron
Copy link
Contributor Author

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)
Copy link
Member

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

@romainneutron romainneutron changed the title [WIP][DependencyInjection] added a simple way to replace a service by keeping a reference to the old one [DependencyInjection] added a simple way to replace a service by keeping a reference to the old one Apr 1, 2014
@romainneutron
Copy link
Contributor Author

PR updated, @stof comments addressed

if (!$decorated = $definition->getDecoratedService()) {
continue;
}
$definition->setDecoratedService(null);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fabpot added a commit that referenced this pull request Apr 1, 2014
…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
@fabpot fabpot merged commit 140f807 into symfony:master Apr 1, 2014
@romainneutron romainneutron deleted the fabpot-sc-decorator branch April 1, 2014 16:31
weaverryan added a commit to symfony/symfony-docs that referenced this pull request May 29, 2014
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants