Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DependencyInjection] Deprecate scope concept#14984

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:2.8fromdosten:dependency-injection/deprecate-scope-concept
Jun 24, 2015
Merged

[DependencyInjection] Deprecate scope concept#14984

fabpot merged 1 commit intosymfony:2.8fromdosten:dependency-injection/deprecate-scope-concept
Jun 24, 2015

Conversation

dosten
Copy link
Contributor

QA
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?yes
Tests pass?yes
LicenseMIT

This PR mark as deprecated the concept of scopes in the DI container. See#10557 (comment).
Also adds a newshared flag to the service definitions in replacement of theprototype scope.

@dostendosten changed the title[DependencyInjection] Deprecate scope concept[WIP][DependencyInjection] Deprecate scope conceptJun 15, 2015
@stof
Copy link
Member

You need to make sure that core code does not trigger such deprecation though (for therequest service for instance).

and the loaders should trigger their own deprecations when usingscope to have a better message (same than done in a few other places)

@dosten
Copy link
ContributorAuthor

@stof The only cases in the core code are therequest scope and thetest.client service with theprototype scope. What's the best approach?

@fabpot
Copy link
Member

@dosten As you can see on Travis, there are still many tests that need to be moved as legacy ones. For thetest.client, I think that we need to keep theprototype scope as it was done before the introduction of scopes. Back then, we had a flag for prototype. As we decided to call itfactory in Pimple (as this is where prototypes make more sense), I think we can add afactory flag which would replace theprototype scope.

@dosten
Copy link
ContributorAuthor

@fabpot Thank you for your feedback, I didn't have enough time to continue with this PR. I'll work on this soon.
I've searched for the flag that you refer, and I have found this commit1d5b6ed. Are you refering to theshared flag?
IMO if we add afactory flag this would be confusing, we already have the concept of factories in the DI.shared is a good name IMO.

@dosten
Copy link
ContributorAuthor

I've added a initial implementation of ashared flag in the service definition, so any service that sets this flag asfalse will return a new instance every time, like theprototype scope. There is many failing tests because the deprecation messages, but i want to discuss this before fix the tests.

@dosten
Copy link
ContributorAuthor

I can't trigger an error on the methods of theContainerInterface because the BC promise, any idea?

@fabpot
Copy link
Member

@dosten I was indeed refering to the oldshared flag (and you are right that using factory like in Pimple is probably confusing). ping @symfony/deciders

@Tobion
Copy link
Contributor

shared makes sense to me.

@dostendosten changed the title[WIP][DependencyInjection] Deprecate scope concept[DependencyInjection] Deprecate scope conceptJun 24, 2015
@dosten
Copy link
ContributorAuthor

@fabpot This PR is ready to be reviewed.

@Tobion
Copy link
Contributor

👍 good job

*/
public function setShared($shared)
{
$this->shared = (bool) $shared;
Copy link
Member

Choose a reason for hiding this comment

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

Do we really want to cast here? The docblock is explicit about the expected type.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

We actually cast in the other methods of theDefinition class

@fabpot
Copy link
Member

👍

@dosten
Copy link
ContributorAuthor

@fabpot Comments addressed

@fabpot
Copy link
Member

Thank you@dosten.

@fabpotfabpot merged commit6c4a676 intosymfony:2.8Jun 24, 2015
fabpot added a commit that referenced this pull requestJun 24, 2015
This PR was merged into the 2.8 branch.Discussion----------[DependencyInjection] Deprecate scope concept| Q             | A| ------------- | ---| Bug fix?      | no| New feature?  | yes| BC breaks?    | no| Deprecations? | yes| Tests pass?   | yes| License       | MITThis PR mark as deprecated the concept of scopes in the DI container. See#10557 (comment).Also adds a new `shared` flag to the service definitions in replacement of the `prototype` scope.Commits-------6c4a676 Add "shared" flag and deprecate scopes concept
@dostendosten deleted the dependency-injection/deprecate-scope-concept branchJune 24, 2015 16:23
if (isset($service['scope'])) {
$definition->setScope($service['scope']);
if ('request' !== $id) {
@trigger_error(sprintf('The "scope" key in file "%s" is deprecated since version 2.8 and will be removed in 3.0.', $file), E_USER_DEPRECATED);
Copy link
Member

Choose a reason for hiding this comment

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

the deprecation message should mention the service id IMO to make it easier to understand

Copy link
Member

Choose a reason for hiding this comment

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

weaverryan added a commit to symfony/symfony-docs that referenced this pull requestNov 30, 2015
…outerJ)This PR was merged into the 2.8 branch.Discussion----------Added minimal cookbook article about the shared flag| Q | A| --- | ---| Doc fix? | no| New docs? | yes (symfony/symfony#14984)| Applies to | 2.8+| Fixed tickets |#5437Commits-------943ee0c Added minimal cookbook article about shared
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@dosten@stof@fabpot@Tobion@xabbuh

[8]ページ先頭

©2009-2025 Movatter.jp