protected function PhpArrayDumper::dumpValue in Service Container 7
Same name and namespace in other branches
- 7.2 lib/Drupal/Core/DependencyInjection/Dumper/PhpArrayDumper.php \Drupal\Core\DependencyInjection\Dumper\PhpArrayDumper::dumpValue()
Dumps the value to YAML format.
Parameters
mixed $value:
Return value
mixed
Throws
RuntimeException When trying to dump object or resource
1 call to PhpArrayDumper::dumpValue()
- PhpArrayDumper::getServiceDefinition in lib/
Drupal/ Core/ DependencyInjection/ Dumper/ PhpArrayDumper.php - Gets a service definition as PHP array.
File
- lib/
Drupal/ Core/ DependencyInjection/ Dumper/ PhpArrayDumper.php, line 290 - Contains \Drupal\Core\DependencyInjection\Dumper\PhpArrayDumper
Class
- PhpArrayDumper
- PhpArrayDumper dumps a service container as a serialized PHP array.
Namespace
Drupal\Core\DependencyInjection\DumperCode
protected function dumpValue($value) {
if (is_array($value)) {
$code = array();
foreach ($value as $k => $v) {
$code[$k] = $this
->dumpValue($v);
}
return $code;
}
elseif ($value instanceof Reference) {
return $this
->getServiceCall((string) $value, $value);
}
elseif ($value instanceof Definition) {
return $this
->getPrivateService($value);
}
elseif ($value instanceof Parameter) {
return $this
->getParameterCall((string) $value);
}
elseif ($value instanceof Expression) {
return $this
->getExpressionCall((string) $value);
}
elseif (is_object($value)) {
if (isset($value->_serviceId)) {
return '@' . $value->_serviceId;
}
throw new RuntimeException('Unable to dump a service container if a parameter is an object without _serviceId.');
}
elseif (is_resource($value)) {
throw new RuntimeException('Unable to dump a service container if a parameter is a resource.');
}
return $value;
}