You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Argument/TaggedIteratorArgument.php
+12-5Lines changed: 12 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -24,12 +24,13 @@ class TaggedIteratorArgument extends IteratorArgument
24
24
private$needsIndexes = false;
25
25
26
26
/**
27
-
* @param string $tag The name of the tag identifying the target services
28
-
* @param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the tagged collection
29
-
* @param string|null $defaultIndexMethod The static method that should be called to get each service's key when their tag doesn't define the previous attribute
30
-
* @param bool $needsIndexes Whether indexes are required and should be generated when computing the map
27
+
* @param string $tag The name of the tag identifying the target services
28
+
* @param string|null $indexAttribute The name of the attribute that defines the key referencing each service in the tagged collection
29
+
* @param string|null $defaultIndexMethod The static method that should be called to get each service's key when their tag doesn't define the previous attribute
30
+
* @param bool $needsIndexes Whether indexes are required and should be generated when computing the map
31
+
* @param string|null $defaultPriorityMethod The static method that should be called to get each service's priority when their tag doesn't define the "priority" attribute
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ CHANGELOG
11
11
* deprecated passing an instance of `Symfony\Component\DependencyInjection\Parameter` as class name to `Symfony\Component\DependencyInjection\Definition`
12
12
* added support for binding iterable and tagged services
13
13
* made singly-implemented interfaces detection be scoped by file
14
+
* added ability to define a static priority method for tagged service
if (($r = $container->getReflectionClass($class)) && $r->hasMethod($defaultPriorityMethod)) {
65
+
if (!($rm = $r->getMethod($defaultPriorityMethod))->isStatic()) {
66
+
thrownewInvalidArgumentException(sprintf('Method "%s::%s()" should be static: tag "%s" on service "%s".', $class, $defaultPriorityMethod, $tagName, $serviceId));
67
+
}
68
+
69
+
if (!$rm->isPublic()) {
70
+
thrownewInvalidArgumentException(sprintf('Method "%s::%s()" should be public: tag "%s" on service "%s".', $class, $defaultPriorityMethod, $tagName, $serviceId));
71
+
}
72
+
73
+
$priority = $rm->invoke(null);
74
+
75
+
if (!\is_int($priority)) {
76
+
thrownewInvalidArgumentException(sprintf('Method "%s::%s()" should return an integer, got %s: tag "%s" on service "%s".', $class, $defaultPriorityMethod, \gettype($priority), $tagName, $serviceId));
0 commit comments