Skip to content

[DI] Introduce "container.service_locator" tag, replaces ServiceLocatorArgument #22024

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
Mar 17, 2017

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Mar 16, 2017

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no (master only)
Deprecations? no
Tests pass? yes
Fixed tickets -
License MIT
Doc PR -

I first started working on adding this new "container.service_locator" tag, so here it is.
It allows defining and dumping service-locator services properly, where it wasn't possible previously (you had to create a DI extension to do so.)

Then I realized that this allowed us to entirely drop ServiceLocatorArgument and replace it with the more flexible ServiceClosureArgument.

This makes things simpler overall, see diff stat.

@nicolas-grekas nicolas-grekas added this to the 3.3 milestone Mar 16, 2017
@nicolas-grekas nicolas-grekas force-pushed the di-service-locator-tag branch 5 times, most recently from ec2285b to d097928 Compare March 16, 2017 15:14
Copy link
Member

@chalasr chalasr left a comment

Choose a reason for hiding this comment

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

Makes good sense to me 👍

Copy link
Contributor

@GuilhemN GuilhemN left a comment

Choose a reason for hiding this comment

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

👍

<argument key="session" type="service" id="session" on-invalid="null" />
<argument type="service">
<service class="Symfony\Component\DependencyInjection\ServiceLocator">
<tag name="service_locator" />
Copy link
Member

Choose a reason for hiding this comment

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

Almost all other tags are of the "X.Y" form. Not sure if we need to call it container.service_locator.

Copy link
Member Author

Choose a reason for hiding this comment

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

tag renamed to container.service_locator

@nicolas-grekas nicolas-grekas force-pushed the di-service-locator-tag branch from d097928 to fb016d6 Compare March 17, 2017 16:48
@nicolas-grekas nicolas-grekas changed the title [DI] Introduce "service_locator" tag, replaces ServiceLocatorArgument [DI] Introduce "container.service_locator" tag, replaces ServiceLocatorArgument Mar 17, 2017
@nicolas-grekas nicolas-grekas force-pushed the di-service-locator-tag branch from fb016d6 to 5d230b5 Compare March 17, 2017 16:49
@fabpot
Copy link
Member

fabpot commented Mar 17, 2017

Thank you @nicolas-grekas.

@fabpot fabpot merged commit 5d230b5 into symfony:master Mar 17, 2017
fabpot added a commit that referenced this pull request Mar 17, 2017
…es ServiceLocatorArgument (nicolas-grekas)

This PR was merged into the 3.3-dev branch.

Discussion
----------

[DI] Introduce "container.service_locator" tag, replaces ServiceLocatorArgument

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no (master only)
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

I first started working on adding this new "container.service_locator" tag, so here it is.
It allows defining and dumping service-locator services properly, where it wasn't possible previously (you had to create a DI extension to do so.)

Then I realized that this allowed us to entirely drop `ServiceLocatorArgument` and replace it with the more flexible `ServiceClosureArgument`.

This makes things simpler overall, see diff stat.

Commits
-------

5d230b5 [DI] Introduce "container.service_locator" tag, replaces ServiceLocatorArgument
@sstok
Copy link
Contributor

sstok commented Mar 18, 2017

If you always use Definition to define a ServiceLocator would it make sense to add ServiceLocatorDefinition of sorts? So you don't have to remember adding the tag every time.

sstok added a commit to rollerworks/PasswordStrengthBundle that referenced this pull request Mar 18, 2017
This PR was merged into the 1.5-dev branch.

Discussion
----------

Related to symfony/symfony#22024

Let's hope I don't have to fix this again 😅

Commits
-------

2fa6076 Fix tests failure for Symfony 3.3-dev
@nicolas-grekas nicolas-grekas deleted the di-service-locator-tag branch March 19, 2017 09:55
@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Mar 19, 2017

@sstok adding ServiceLocatorDefinition would create a new type, unwanted to me. A helper method would do the job equally well. But right now, I don't feel the need for one personally.

sstok added a commit to rollerworks/RollerworksSearchBundle that referenced this pull request Mar 19, 2017
This PR was merged into the 2.0-dev branch.

Discussion
----------

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | 
| License       | MIT

Symfony 3.3-dev changed the way how ServiceLocators are registered
symfony/symfony#22024

Commits
-------

e2c028b Fix compatibility for latest Symfony version
@fabpot fabpot mentioned this pull request May 1, 2017
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request May 4, 2017
…guiluz)

This PR was merged into the master branch.

Discussion
----------

[DI] Add section about service locators

Adds documentation for symfony/symfony#21553 and symfony/symfony#22024.
Any suggestion will be much appreciated, as usual.

Commits
-------

fa19770 Fix service locator declaration
f5e4942 Rewords
5efacd0 [DI] Add section about Service Locators
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants