protected function OptimizedPhpArrayDumper::getServiceDefinition in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php \Drupal\Component\DependencyInjection\Dumper\OptimizedPhpArrayDumper::getServiceDefinition()
Gets a service definition as PHP array.
Parameters
\Symfony\Component\DependencyInjection\Definition $definition: The definition to process.
Return value
array The service definition as PHP array.
Throws
\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException Thrown when the definition is marked as decorated, or with an explicit scope different from SCOPE_CONTAINER and SCOPE_PROTOTYPE.
2 calls to OptimizedPhpArrayDumper::getServiceDefinition()
- OptimizedPhpArrayDumper::getPrivateServiceCall in core/
lib/ Drupal/ Component/ DependencyInjection/ Dumper/ OptimizedPhpArrayDumper.php - Gets a private service definition in a suitable format.
- OptimizedPhpArrayDumper::getServiceDefinitions in core/
lib/ Drupal/ Component/ DependencyInjection/ Dumper/ OptimizedPhpArrayDumper.php - Gets services of the container as a PHP array.
File
- core/
lib/ Drupal/ Component/ DependencyInjection/ Dumper/ OptimizedPhpArrayDumper.php, line 209
Class
- OptimizedPhpArrayDumper
- OptimizedPhpArrayDumper dumps a service container as a serialized PHP array.
Namespace
Drupal\Component\DependencyInjection\DumperCode
protected function getServiceDefinition(Definition $definition) {
$service = [];
if ($definition
->getClass()) {
$service['class'] = $definition
->getClass();
}
if (!$definition
->isPublic()) {
$service['public'] = FALSE;
}
if ($definition
->getFile()) {
$service['file'] = $definition
->getFile();
}
if ($definition
->isSynthetic()) {
$service['synthetic'] = TRUE;
}
if ($definition
->isLazy()) {
$service['lazy'] = TRUE;
}
if ($definition
->getArguments()) {
$arguments = $definition
->getArguments();
$service['arguments'] = $this
->dumpCollection($arguments);
$service['arguments_count'] = count($arguments);
}
else {
$service['arguments_count'] = 0;
}
if ($definition
->getProperties()) {
$service['properties'] = $this
->dumpCollection($definition
->getProperties());
}
if ($definition
->getMethodCalls()) {
$service['calls'] = $this
->dumpMethodCalls($definition
->getMethodCalls());
}
// By default services are shared, so just provide the flag, when needed.
if ($definition
->isShared() === FALSE) {
$service['shared'] = $definition
->isShared();
}
if (($decorated = $definition
->getDecoratedService()) !== NULL) {
throw new InvalidArgumentException("The 'decorated' definition is not supported by the Drupal 8 run-time container. The Container Builder should have resolved that during the DecoratorServicePass compiler pass.");
}
if ($callable = $definition
->getFactory()) {
$service['factory'] = $this
->dumpCallable($callable);
}
if ($callable = $definition
->getConfigurator()) {
$service['configurator'] = $this
->dumpCallable($callable);
}
return $service;
}