private function InlineServiceDefinitionsPass::isInlineableDefinition

Checks if the definition is inlineable.

Parameters

ContainerBuilder $container:

string $id:

Definition $definition:

Return value

Boolean If the definition is inlineable

1 call to InlineServiceDefinitionsPass::isInlineableDefinition()
InlineServiceDefinitionsPass::inlineArguments in drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php
Processes inline arguments.

File

drupal/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Compiler/InlineServiceDefinitionsPass.php, line 112

Class

InlineServiceDefinitionsPass
Inline service definitions where this is possible.

Namespace

Symfony\Component\DependencyInjection\Compiler

Code

private function isInlineableDefinition(ContainerBuilder $container, $id, Definition $definition) {
  if (ContainerInterface::SCOPE_PROTOTYPE === $definition
    ->getScope()) {
    return true;
  }
  if ($definition
    ->isPublic()) {
    return false;
  }
  if (!$this->graph
    ->hasNode($id)) {
    return true;
  }
  $ids = array();
  foreach ($this->graph
    ->getNode($id)
    ->getInEdges() as $edge) {
    $ids[] = $edge
      ->getSourceNode()
      ->getId();
  }
  if (count(array_unique($ids)) > 1) {
    return false;
  }
  return $container
    ->getDefinition(reset($ids))
    ->getScope() === $definition
    ->getScope();
}