You are here

protected function PhpArrayDumper::getServiceDefinition in Service Container 7.2

Same name and namespace in other branches
  1. 7 lib/Drupal/Core/DependencyInjection/Dumper/PhpArrayDumper.php \Drupal\Core\DependencyInjection\Dumper\PhpArrayDumper::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.

2 calls to PhpArrayDumper::getServiceDefinition()
PhpArrayDumper::getPrivateService in lib/Drupal/Core/DependencyInjection/Dumper/PhpArrayDumper.php
Returns a private service definition in a suitable format.
PhpArrayDumper::getServiceDefinitions in lib/Drupal/Core/DependencyInjection/Dumper/PhpArrayDumper.php
Returns services of the container as a PHP Array.

File

lib/Drupal/Core/DependencyInjection/Dumper/PhpArrayDumper.php, line 151
Contains \Drupal\Core\DependencyInjection\Dumper\PhpArrayDumper

Class

PhpArrayDumper
PhpArrayDumper dumps a service container as a serialized PHP array.

Namespace

Drupal\Core\DependencyInjection\Dumper

Code

protected function getServiceDefinition($definition) {
  $service = array();
  if ($definition
    ->getClass()) {
    $service['class'] = $definition
      ->getClass();
  }
  if (!$definition
    ->isPublic()) {
    $service['public'] = FALSE;
  }
  $tags = $definition
    ->getTags();
  if (!empty($tags)) {
    foreach ($tags as $tag => $attributes) {
      $tag = [
        'name' => $tag,
      ];
      foreach ($attributes as $attribute) {
        $tag += $attribute;
      }
      $service['tags'][] = $tag;
    }
  }
  if ($definition
    ->getFile()) {
    $service['file'] = $definition
      ->getFile();
  }
  if ($definition
    ->isSynthetic()) {
    $service['synthetic'] = TRUE;
  }
  if ($definition
    ->isLazy()) {
    $service['lazy'] = TRUE;
  }
  if ($definition
    ->getArguments()) {
    $service['arguments'] = $this
      ->dumpValue($definition
      ->getArguments());
  }
  if ($definition
    ->getProperties()) {
    $service['properties'] = $this
      ->dumpValue($definition
      ->getProperties());
  }
  if ($definition
    ->getMethodCalls()) {
    $service['calls'] = $this
      ->dumpValue($definition
      ->getMethodCalls());
  }
  if (($scope = $definition
    ->getScope()) !== ContainerInterface::SCOPE_CONTAINER) {
    $service['scope'] = $scope;
  }
  if (($decorated = $definition
    ->getDecoratedService()) !== NULL) {
    $service['decorates'] = $decorated;
  }
  if ($callable = $definition
    ->getFactory()) {
    $service['factory'] = $this
      ->dumpCallable($callable);
  }
  if ($callable = $definition
    ->getConfigurator()) {
    $service['configurator'] = $this
      ->dumpCallable($callable);
  }
  return $service;
}