-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Documented "Handling decorations on non existent service" #12442
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
OskarStark
merged 1 commit into
symfony:4.4
from
mtarld:feature/behavior-on-decorated-invalid
Feb 15, 2020
Merged
Documented "Handling decorations on non existent service" #12442
OskarStark
merged 1 commit into
symfony:4.4
from
mtarld:feature/behavior-on-decorated-invalid
Feb 15, 2020
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OskarStark
reviewed
Oct 11, 2019
OskarStark
reviewed
Oct 11, 2019
OskarStark
reviewed
Oct 11, 2019
OskarStark
reviewed
Oct 11, 2019
OskarStark
reviewed
Oct 11, 2019
OskarStark
reviewed
Oct 11, 2019
OskarStark
reviewed
Oct 11, 2019
OskarStark
reviewed
Oct 11, 2019
OskarStark
reviewed
Oct 11, 2019
OskarStark
reviewed
Oct 11, 2019
fabpot
added a commit
to symfony/symfony
that referenced
this pull request
Nov 3, 2019
…non existent decorated services (mtarld) This PR was merged into the 4.4 branch. Discussion ---------- [DI] Add ability to choose behavior of decorations on non existent decorated services | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #33522 | License | MIT | Doc PR | symfony/symfony-docs#12442 # Handling decorations on non existent decorated services Handle decorations on non existent decorated services by either throwing the service not found exception, silently ignoring services (decorator & decorated) all together or leave the decorated service to null (current behavior) Something almost similar to how missing services as parameters are handles. ## Yaml configuration ```yaml decorator: decorates: decorated decoration_on_invalid: ignore ``` Available values: `exception`, `ignore`, `null`. `exception` if nothing is specified. ## Xml configuration ```xml <service id="decorator" decorates="decorated" decoration-on-invalid="ignore" /> ``` Available values: `exception`, `ignore`, `null`. `exception` if nothing is specified. ## Behavior - `exception`: Throws a `ServiceNotFoundException` telling that the decorator's dependency is missing - `ignore`: Remove decorator definition. Decorator and decorated will not be available at all. - `null`: Keep decorator but set decorated to null. Therefore, decorator `__construct` should be written with a nullable decorated dependency (`public function __contruct(?DecoratedInterface $decorated) {}`) and check should be done in other methods Commits ------- f167c77 Handle non existent decorated services
symfony-splitter
pushed a commit
to symfony/dependency-injection
that referenced
this pull request
Nov 3, 2019
…non existent decorated services (mtarld) This PR was merged into the 4.4 branch. Discussion ---------- [DI] Add ability to choose behavior of decorations on non existent decorated services | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | #33522 | License | MIT | Doc PR | symfony/symfony-docs#12442 # Handling decorations on non existent decorated services Handle decorations on non existent decorated services by either throwing the service not found exception, silently ignoring services (decorator & decorated) all together or leave the decorated service to null (current behavior) Something almost similar to how missing services as parameters are handles. ## Yaml configuration ```yaml decorator: decorates: decorated decoration_on_invalid: ignore ``` Available values: `exception`, `ignore`, `null`. `exception` if nothing is specified. ## Xml configuration ```xml <service id="decorator" decorates="decorated" decoration-on-invalid="ignore" /> ``` Available values: `exception`, `ignore`, `null`. `exception` if nothing is specified. ## Behavior - `exception`: Throws a `ServiceNotFoundException` telling that the decorator's dependency is missing - `ignore`: Remove decorator definition. Decorator and decorated will not be available at all. - `null`: Keep decorator but set decorated to null. Therefore, decorator `__construct` should be written with a nullable decorated dependency (`public function __contruct(?DecoratedInterface $decorated) {}`) and check should be done in other methods Commits ------- f167c77eaf Handle non existent decorated services
HeahDude
suggested changes
Feb 13, 2020
e2a4449
to
46883da
Compare
HeahDude
approved these changes
Feb 13, 2020
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.
LGTM, thanks!
46883da
to
5e9a253
Compare
HeahDude
reviewed
Feb 13, 2020
5e9a253
to
c0fa50e
Compare
HeahDude
reviewed
Feb 14, 2020
c0fa50e
to
cb07e30
Compare
Thanks for your work on this new feature! |
OskarStark
added a commit
that referenced
this pull request
Feb 15, 2020
…ce" (mtarld) This PR was merged into the 4.4 branch. Discussion ---------- Documented "Handling decorations on non existent service" Documentation part for the PR: symfony/symfony#33854 Commits ------- cb07e30 Add "Handling decorations on non existent service"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Documentation part for the PR:
symfony/symfony#33854