Skip to content
Snippets Groups Projects

Tagged iterator for 10.3.x

9 files
+ 121
10
Compare changes
  • Side-by-side
  • Inline
Files
9
@@ -306,9 +306,6 @@ 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);
@@ -438,6 +435,9 @@ protected function dumpValue($value) {
return $this->getServiceClosureCall((string) $reference, $reference->getInvalidBehavior());
}
elseif ($value instanceof IteratorArgument) {
return $this->getIterator($value);
}
elseif (is_object($value)) {
// Drupal specific: Instantiated objects have a _serviceId parameter.
if (isset($value->_serviceId)) {
@@ -555,4 +555,20 @@ protected function getServiceClosureCall(string $id, int $invalid_behavior = Con
];
}
/**
* Gets a service iterator in a suitable PHP array format.
*
* @param \Symfony\Component\DependencyInjection\Argument\IteratorArgument $iterator
* The iterator.
*
* @return object
* The PHP array representation of the iterator.
*/
protected function getIterator(IteratorArgument $iterator) {
return (object) [
'type' => 'iterator',
'value' => array_map($this->dumpValue(...), $iterator->getValues()),
];
}
}
Loading