protected OptimizedPhpArrayDumper::dumpCollection($collection, &$resolve = FALSE)
Dumps a collection to a PHP array.
mixed $collection: A collection to process.
bool &$resolve: Used for passing the information to the caller whether the given collection needed to be resolved or not. This is used for optimizing deep arrays that don't need to be traversed.
\stdClass|array The collection in a suitable format.
protected function dumpCollection($collection, &$resolve = FALSE) { $code = array(); foreach ($collection as $key => $value) { if (is_array($value)) { $resolve_collection = FALSE; $code[$key] = $this->dumpCollection($value, $resolve_collection); if ($resolve_collection) { $resolve = TRUE; } } else { if (is_object($value)) { $resolve = TRUE; } $code[$key] = $this->dumpValue($value); } } if (!$resolve) { return $collection; } return (object) array( 'type' => 'collection', 'value' => $code, 'resolve' => $resolve, ); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!DependencyInjection!Dumper!OptimizedPhpArrayDumper.php/function/OptimizedPhpArrayDumper::dumpCollection/8.1.x