Verified Commit 8b6814e4 authored by Dave Long's avatar Dave Long
Browse files

Issue #2961380 by alexpott, manishsaharan, borisson_, kim.pepper, znerol:...

Issue #2961380 by alexpott, manishsaharan, borisson_, kim.pepper, znerol: Support IteratorArgument in \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper::dumpValue
parent c271adbb
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
namespace Drupal\Component\DependencyInjection\Dumper;

use Drupal\Component\Utility\Crypt;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Definition;
@@ -305,6 +306,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);
+4 −0
Original line number Diff line number Diff line
@@ -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);
      }
+8 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
  use Prophecy\PhpUnit\ProphecyTrait;
  use Prophecy\Prophet;
  use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
  use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
  use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
  use Symfony\Component\DependencyInjection\Definition;
  use Symfony\Component\DependencyInjection\Reference;
@@ -349,6 +350,13 @@ public static function getDefinitionsDataProvider() {
        'arguments_expected' => static::getCollection([static::getCollection([static::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' => static::getCollection([static::getCollection([static::getServiceCall('bar')])]),
      ] + $base_service_definition;

      // Test a collection with a variable to resolve.
      $service_definitions[] = [
        'arguments' => [new Parameter('llama_parameter')],