-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Define default priority inside service class #31943
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e2138ad
Define default priority inside service class
pcabreus bd88e1e
Update YamlFileLoader.php
pcabreus 2df617e
added ability to define an priority method for a tagged collection
pcabreus 4fed2a3
Merge branch '4.4' into patch-1
pcabreus b6069b2
fixed fabbot.io code standard
pcabreus 5498824
fixed spell
pcabreus 8ab9cfd
compare using null
pcabreus f48eea9
better exception decription
pcabreus c021fc8
fixed some code standard
pcabreus 2d8fd1f
fixed some code standard
pcabreus 6b51ac5
fixed arguments order
pcabreus b9dd5eb
using the `tagged_iterator` instead deprecated `tagged`
pcabreus 41f5e99
optional priority method unless you define it
pcabreus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
added ability to define an priority method for a tagged collection
- Loading branch information
commit 2df617e1e851fa0cacf1b0eec4aef8f010870983
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,22 +115,39 @@ function iterator(array $values): IteratorArgument | |
|
||
/** | ||
* Creates a lazy iterator by tag name. | ||
* | ||
* @param string $tag | ||
* @param string|null $indexAttribute | ||
* @param string|null $defaultIndexMethod | ||
* @param bool $needsIndexes | ||
* @param string|null $defaultPriorityMethod | ||
* @return TaggedIteratorArgument | ||
pcabreus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
function tagged(string $tag, string $indexAttribute = null, string $defaultIndexMethod = null): TaggedIteratorArgument | ||
function tagged(string $tag, string $indexAttribute = null, string $defaultIndexMethod = null, bool $needsIndexes = false, string $defaultPriorityMethod = null): TaggedIteratorArgument | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be reverted, this function is deprecated, no need to alter it |
||
{ | ||
return new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod); | ||
return new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod,$needsIndexes, $defaultPriorityMethod); | ||
} | ||
|
||
/** | ||
* Creates a service locator by tag name. | ||
* | ||
* @param string $tag | ||
* @param string $indexAttribute | ||
* @param string|null $defaultIndexMethod | ||
* @param bool $needsIndexes | ||
* @param string|null $defaultPriorityMethod | ||
* @return ServiceLocatorArgument | ||
*/ | ||
function tagged_locator(string $tag, string $indexAttribute, string $defaultIndexMethod = null): ServiceLocatorArgument | ||
function tagged_locator(string $tag, string $indexAttribute, string $defaultIndexMethod = null, bool $needsIndexes = true, string $defaultPriorityMethod = null): ServiceLocatorArgument | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. $needsIndexes should be removed, it's always true for locators |
||
{ | ||
return new ServiceLocatorArgument(new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod, true)); | ||
return new ServiceLocatorArgument(new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod, $needsIndexes, $defaultPriorityMethod)); | ||
} | ||
|
||
/** | ||
* Creates an expression. | ||
* | ||
* @param string $expression | ||
* @return Expression | ||
*/ | ||
function expr(string $expression): Expression | ||
{ | ||
|
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
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
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
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
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
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
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
17 changes: 17 additions & 0 deletions
17
...Component/DependencyInjection/Tests/Fixtures/xml/services_with_tagged_priority_method.xml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true"/> | ||
<service id="foo" class="Foo"> | ||
<tag name="foo_tag"/> | ||
</service> | ||
<service id="foo_tagged_iterator" class="Bar" public="true"> | ||
<argument type="tagged" tag="foo_tag" default-priority-method="foopriority"/> | ||
</service> | ||
<service id="foo_tagged_locator" class="Bar" public="true"> | ||
<argument type="tagged_locator" tag="foo_tag" default-priority-method="foopriority"/> | ||
</service> | ||
<service id="Psr\Container\ContainerInterface" alias="service_container" public="false"/> | ||
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false"/> | ||
</services> | ||
</container> |
22 changes: 22 additions & 0 deletions
22
...omponent/DependencyInjection/Tests/Fixtures/yaml/services_with_tagged_priority_method.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
services: | ||
service_container: | ||
class: Symfony\Component\DependencyInjection\ContainerInterface | ||
public: true | ||
synthetic: true | ||
foo_service: | ||
class: Foo | ||
tags: | ||
- { name: foo } | ||
foo_service_tagged_iterator: | ||
class: Bar | ||
arguments: [!tagged { tag: foo, default_priority_method: foopriority }] | ||
foo_service_tagged_locator: | ||
class: Bar | ||
arguments: [!tagged_locator { tag: foo, default_priority_method: foopriority }] | ||
Psr\Container\ContainerInterface: | ||
alias: service_container | ||
public: false | ||
Symfony\Component\DependencyInjection\ContainerInterface: | ||
alias: service_container | ||
public: false |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.