-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[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
Changes from 10 commits
e2138ad
bd88e1e
2df617e
4fed2a3
b6069b2
5498824
8ab9cfd
f48eea9
c021fc8
2d8fd1f
6b51ac5
b9dd5eb
41f5e99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,27 +118,27 @@ function iterator(array $values): IteratorArgument | |
* | ||
* @deprecated since Symfony 4.4, to be removed in 5.0, use "tagged_iterator" instead. | ||
*/ | ||
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 |
||
{ | ||
@trigger_error(__NAMESPACE__.'\tagged() is deprecated since Symfony 4.4 and will be removed in 5.0, use '.__NAMESPACE__.'\tagged_iterator() instead.', E_USER_DEPRECATED); | ||
|
||
return new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod); | ||
return new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod, $needsIndexes, $defaultPriorityMethod); | ||
} | ||
|
||
/** | ||
* Creates a lazy iterator by tag name. | ||
*/ | ||
function tagged_iterator(string $tag, string $indexAttribute = null, string $defaultIndexMethod = null): TaggedIteratorArgument | ||
function tagged_iterator(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. $needsIndexes should be removed, it's always false for iterators |
||
{ | ||
return new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod); | ||
return new TaggedIteratorArgument($tag, $indexAttribute, $defaultIndexMethod, $needsIndexes, $defaultPriorityMethod); | ||
} | ||
|
||
/** | ||
* Creates a service locator by tag name. | ||
*/ | ||
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)); | ||
} | ||
|
||
/** | ||
|
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> |
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 |
Uh oh!
There was an error while loading. Please reload this page.