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

[FrameworkBundle] Expose the AbstractController's container to its subclasses#23180

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:3.3fromBPScott:expose-abstractcontroller-container
Jun 15, 2017
Merged

[FrameworkBundle] Expose the AbstractController's container to its subclasses#23180

fabpot merged 1 commit intosymfony:3.3fromBPScott:expose-abstractcontroller-container
Jun 15, 2017

Conversation

@BPScott
Copy link
Contributor

QA
Branch?3.3
Bug fix?no
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRn/a

This is useful if an application provides their own base Controller that
references items in the container. It also makes it simpler for that
base controller to add additional optional dependencies by only overriding
getSubscribedServices instead of having to reimplement setContainer and
use ControllerTrait.

@BPScottBPScott changed the titleExpose the AbstractController's container to its subclasses[FrameworkBundle] Expose the AbstractController's container to its subclassesJun 14, 2017
@nicolas-grekasnicolas-grekas added this to the3.3 milestoneJun 15, 2017
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

Even if we usually don't encourage protected properties, I'm 👍 here:
extendingAbstractController::getSubscribedServices() is a legitimate use case that's really missing in 3.3.

Extending setContainer or using ControllerTrait as an alternative is unsupported because both are internal.

Using service argument injection doesn't fit the really-lazy use case (when eg. you first have some authorization check in an action before using a service.)

We could also add get/has methods. Not sure if that'd be better thought. Hence my vote.

use ControllerTrait;

private$container;
protected$container;

Choose a reason for hiding this comment

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

Pleas add a docblock comment to help IDE with the type of this.

Useful if an application provides their own base Controller thatreferences items in the container. It also makes it simpler for thatbase controller to add additional optional dependencies by only overridinggetSubscribedServices instead of having to reimplement setContainer anduse ControllerTrait.
@BPScott
Copy link
ContributorAuthor

Added the docblock.

Adding the get/has methods would also solve my use-case. Am happy to add those too or in place of changing the visibility if desired.Controller does both (protected $container comes via ContainerAwareTrait).

Laziness is exactly the use case I'm aiming for.This is what I'm trying to do - my base controller will contain various utility methods, and I don't want the overhead of creating the services used by those utilities until I know I need them.

@fabpot
Copy link
Member

Thank you@BPScott.

@fabpotfabpot merged commitee17131 intosymfony:3.3Jun 15, 2017
fabpot added a commit that referenced this pull requestJun 15, 2017
…r to its subclasses (BPScott)This PR was merged into the 3.3 branch.Discussion----------[FrameworkBundle] Expose the AbstractController's container to its subclasses| Q             | A| ------------- | ---| Branch?       | 3.3| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        | n/aThis is useful if an application provides their own base Controller thatreferences items in the container. It also makes it simpler for thatbase controller to add additional optional dependencies by only overridinggetSubscribedServices instead of having to reimplement setContainer anduse ControllerTrait.Commits-------ee17131 Expose the AbstractController's container to its subclasses
@BPScottBPScott deleted the expose-abstractcontroller-container branchJune 15, 2017 15:46
@fabpotfabpot mentioned this pull requestJul 4, 2017
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

4 participants

@BPScott@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp