X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FDependencyInjection%2FContainerBuilder.php;h=9f510781fbb553b632f5df1056200ae29e68413e;hb=refs%2Fheads%2Fd864;hp=e45cb884aa26960fe6d62ac27a46302fb3c97c9d;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php b/web/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php index e45cb884a..9f510781f 100644 --- a/web/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php +++ b/web/core/lib/Drupal/Core/DependencyInjection/ContainerBuilder.php @@ -27,8 +27,8 @@ class ContainerBuilder extends SymfonyContainerBuilder { * {@inheritdoc} */ public function __construct(ParameterBagInterface $parameterBag = NULL) { - $this->setResourceTracking(FALSE); parent::__construct($parameterBag); + $this->setResourceTracking(FALSE); } /** @@ -46,20 +46,15 @@ class ContainerBuilder extends SymfonyContainerBuilder { } /** - * Direct copy of the parent function. + * A 1to1 copy of parent::shareService. + * + * @todo https://www.drupal.org/project/drupal/issues/2937010 Since Symfony + * 3.4 this is not a 1to1 copy. */ - protected function shareService(Definition $definition, $service, $id) + protected function shareService(Definition $definition, $service, $id, array &$inlineServices) { - if ($definition->isShared() && self::SCOPE_PROTOTYPE !== $scope = $definition->getScope(false)) { - if (self::SCOPE_CONTAINER !== $scope && !isset($this->scopedServices[$scope])) { - throw new InactiveScopeException($id, $scope); - } - + if ($definition->isShared()) { $this->services[$lowerId = strtolower($id)] = $service; - - if (self::SCOPE_CONTAINER !== $scope) { - $this->scopedServices[$scope][$lowerId] = $service; - } } } @@ -74,11 +69,11 @@ class ContainerBuilder extends SymfonyContainerBuilder { * ContainerBuilder class should be fixed to allow setting synthetic * services in a frozen builder. */ - public function set($id, $service, $scope = self::SCOPE_CONTAINER) { + public function set($id, $service) { if (strtolower($id) !== $id) { throw new \InvalidArgumentException("Service ID names must be lowercase: $id"); } - SymfonyContainer::set($id, $service, $scope); + SymfonyContainer::set($id, $service); // Ensure that the _serviceId property is set on synthetic services as well. if (isset($this->services[$id]) && is_object($this->services[$id]) && !isset($this->services[$id]->_serviceId)) { @@ -96,6 +91,32 @@ class ContainerBuilder extends SymfonyContainerBuilder { return parent::register($id, $class); } + /** + * {@inheritdoc} + */ + public function setAlias($alias, $id) { + $alias = parent::setAlias($alias, $id); + // As of Symfony 3.4 all aliases are private by default. + $alias->setPublic(TRUE); + return $alias; + } + + /** + * {@inheritdoc} + */ + 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; + } + /** * {@inheritdoc} */ @@ -108,8 +129,11 @@ class ContainerBuilder extends SymfonyContainerBuilder { /** * A 1to1 copy of parent::callMethod. + * + * @todo https://www.drupal.org/project/drupal/issues/2937010 Since Symfony + * 3.4 this is not a 1to1 copy. */ - protected function callMethod($service, $call) { + protected function callMethod($service, $call, array &$inlineServices = array()) { $services = self::getServiceConditionals($call[1]); foreach ($services as $s) {