function ContainerBuilder::setDefinition

File

core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php, line 107

Class

ContainerBuilder
Drupal's dependency injection container builder.

Namespace

Drupal\Core\DependencyInjection

Code

public function setDefinition($id, Definition $definition) {
  $definition = parent::setDefinition($id, $definition);
  // As of Symfony 3.4 all definitions are private by default.
  // \Symfony\Component\DependencyInjection\Compiler\ResolvePrivatesPassOnly
  // removes services marked as private from the container even if they are
  // also marked as public. Drupal requires services that are public to
  // remain in the container and not be removed.
  if ($definition->isPublic()) {
    $definition->setPrivate(FALSE);
  }
  return $definition;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.