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

Appearance settings

Commit 26e1d89

Browse filesBrowse files
committed
feature #31353 [FrameworkBundle] Show injected services for iterator and array arguments (jschaedl)
This PR was merged into the 4.3-dev branch. Discussion ---------- [FrameworkBundle] Show injected services for iterator and array arguments | Q | A | ------------- | --- | Branch? | master | Bug fix? |no | New feature? | yes<!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? |no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #31340 <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | tbd. When I have the following service configuration: ```yaml App\Word\Checker\StaticWordChecker: tags: [app.checker] App\Word\Checker\BannedWorldListChecker: tags: [app.checker] App\Word\WordCheckerTaggedIterator: arguments: [!tagged app.checker] App\Word\WordCheckerArray: arguments: - App\Word\Checker\StaticWordChecker: ~ App\Word\Checker\BannedWorldListChecker: ~ ``` and I run: `./bin/console debug:container App\Word\WordCheckerArray --show-arguments` ```bash Information for Service "App\Word\WordCheckerArray" =================================================== ---------------- ------------------------------------------- Option Value ---------------- ------------------------------------------- Service ID App\Word\WordCheckerArray Class App\Word\WordCheckerArray Tags - Public no Synthetic no Lazy no Shared yes Abstract no Autowired yes Autoconfigured yes Arguments Array (2 element(s)) - App\Word\Checker\StaticWordChecker - App\Word\Checker\BannedWorldListChecker ---------------- ------------------------------------------- ``` or `./bin/console debug:container App\Word\WordCheckerTaggedIterator --show-arguments` ```bash Information for Service "App\Word\WordCheckerTaggedIterator" ============================================================ ---------------- ------------------------------------------- Option Value ---------------- ------------------------------------------- Service ID App\Word\WordCheckerTaggedIterator Class App\Word\WordCheckerTaggedIterator Tags - Public no Synthetic no Lazy no Shared yes Abstract no Autowired yes Autoconfigured yes Arguments Iterator (2 element(s)) - App\Word\Checker\BannedWorldListChecker - App\Word\Checker\StaticWordChecker ---------------- ------------------------------------------- ``` I can now see the the objects injected into the iterator and array arguments. Commits ------- db5fb20 [FrameworkBundle] Show injected services for Iterator and Array
2 parents b187261 + db5fb20 commit 26e1d89
Copy full SHA for 26e1d89

File tree

2 files changed

+15
-2
lines changed
Filter options

2 files changed

+15
-2
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,12 +348,20 @@ protected function describeContainerDefinition(Definition $definition, array $op
348348
$argumentsInformation[] = sprintf('Service(%s)', (string) $argument);
349349
} elseif ($argument instanceof IteratorArgument) {
350350
$argumentsInformation[] = sprintf('Iterator (%d element(s))', \count($argument->getValues()));
351+
foreach (array_map(function (Reference $value) {return (string) $value; }, $argument->getValues()) as $service) {
352+
$argumentsInformation[] = sprintf('- %s', $service);
353+
}
351354
} elseif ($argument instanceof ServiceLocatorArgument) {
352355
$argumentsInformation[] = sprintf('Service locator (%d element(s))', \count($argument->getValues()));
353356
} elseif ($argument instanceof Definition) {
354357
$argumentsInformation[] = 'Inlined Service';
355358
} else {
356359
$argumentsInformation[] = \is_array($argument) ? sprintf('Array (%d element(s))', \count($argument)) : $argument;
360+
if (\is_array($argument)) {
361+
foreach (array_keys($argument) as $service) {
362+
$argumentsInformation[] = sprintf('- %s', $service);
363+
}
364+
}
357365
}
358366
}
359367

‎src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Descriptor/definition_arguments_1.txt
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
 %parameter% 
1818
 Inlined Service 
1919
 Array (3 element(s)) 
20-
 Iterator (2 element(s))
21-
---------------- -----------------------------
20+
 - 0 
21+
 - 1 
22+
 - 2 
23+
 Iterator (2 element(s)) 
24+
 - definition_1 
25+
 - .definition_2
26+
---------------- -----------------------------
2227

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.