You are here

private function InlineServiceDefinitionsPass::isInlineableDefinition in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/dependency-injection/Compiler/InlineServiceDefinitionsPass.php \Symfony\Component\DependencyInjection\Compiler\InlineServiceDefinitionsPass::isInlineableDefinition()

Checks if the definition is inlineable.

Parameters

ContainerBuilder $container:

string $id:

Definition $definition:

Return value

bool If the definition is inlineable

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

File

vendor/symfony/dependency-injection/Compiler/InlineServiceDefinitionsPass.php, line 120

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() || $definition
    ->isLazy()) {
    return false;
  }
  if (!$this->graph
    ->hasNode($id)) {
    return true;
  }
  if ($this->currentId == $id) {
    return false;
  }
  $ids = array();
  foreach ($this->graph
    ->getNode($id)
    ->getInEdges() as $edge) {
    $ids[] = $edge
      ->getSourceNode()
      ->getId();
  }
  if (count(array_unique($ids)) > 1) {
    return false;
  }
  if (count($ids) > 1 && is_array($factory = $definition
    ->getFactory()) && ($factory[0] instanceof Reference || $factory[0] instanceof Definition)) {
    return false;
  }
  if (count($ids) > 1 && $definition
    ->getFactoryService(false)) {
    return false;
  }
  return $container
    ->getDefinition(reset($ids))
    ->getScope() === $definition
    ->getScope();
}