diff --git a/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php b/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php index c5ce59b448..0c967e195b 100644 --- a/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php +++ b/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php @@ -11,6 +11,7 @@ use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Dumper\Dumper; use Symfony\Component\ExpressionLanguage\Expression; +use Symfony\Component\DependencyInjection\Argument\IteratorArgument; /** * OptimizedPhpArrayDumper dumps a service container as a serialized PHP array. @@ -304,6 +305,9 @@ protected function dumpCollection($collection, &$resolve = FALSE) { $code = []; foreach ($collection as $key => $value) { + if ($value instanceof IteratorArgument) { + $value = $value->getValues(); + } if (is_array($value)) { $resolve_collection = FALSE; $code[$key] = $this->dumpCollection($value, $resolve_collection); diff --git a/core/lib/Drupal/Component/DependencyInjection/Dumper/PhpArrayDumper.php b/core/lib/Drupal/Component/DependencyInjection/Dumper/PhpArrayDumper.php index a6fa2b9b09..08451b1139 100644 --- a/core/lib/Drupal/Component/DependencyInjection/Dumper/PhpArrayDumper.php +++ b/core/lib/Drupal/Component/DependencyInjection/Dumper/PhpArrayDumper.php @@ -2,6 +2,7 @@ namespace Drupal\Component\DependencyInjection\Dumper; +use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -33,6 +34,9 @@ protected function dumpCollection($collection, &$resolve = FALSE) { $code = []; foreach ($collection as $key => $value) { + if ($value instanceof IteratorArgument) { + $value = $value->getValues(); + } if (is_array($value)) { $code[$key] = $this->dumpCollection($value); } diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php index a026d89aac..7540f37ca0 100644 --- a/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php +++ b/core/tests/Drupal/Tests/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumperTest.php @@ -19,6 +19,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; + use Symfony\Component\DependencyInjection\Argument\IteratorArgument; /** * @coversDefaultClass \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper @@ -330,6 +331,13 @@ public function getDefinitionsDataProvider() { 'arguments_expected' => $this->getCollection([$this->getCollection([$this->getServiceCall('bar')])]), ] + $base_service_definition; + // Test an IteratorArgument collection with a reference to resolve. + $service_definitions[] = [ + 'arguments' => [new IteratorArgument([new Reference('bar')])], + 'arguments_count' => 1, + 'arguments_expected' => $this->getCollection([$this->getCollection([$this->getServiceCall('bar')])]), + ] + $base_service_definition; + // Test a collection with a variable to resolve. $service_definitions[] = [ 'arguments' => [new Parameter('llama_parameter')],