Chris@0: setResourceTracking(FALSE); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Retrieves the currently set proxy instantiator or instantiates one. Chris@0: * Chris@0: * @return InstantiatorInterface Chris@0: */ Chris@0: private function getProxyInstantiator() Chris@0: { Chris@0: if (!$this->proxyInstantiator) { Chris@0: $this->proxyInstantiator = new RealServiceInstantiator(); Chris@0: } Chris@0: Chris@0: return $this->proxyInstantiator; Chris@0: } Chris@0: Chris@0: /** Chris@14: * A 1to1 copy of parent::shareService. Chris@14: * Chris@14: * @todo https://www.drupal.org/project/drupal/issues/2937010 Since Symfony Chris@14: * 3.4 this is not a 1to1 copy. Chris@0: */ Chris@14: protected function shareService(Definition $definition, $service, $id, array &$inlineServices) Chris@0: { Chris@0: if ($definition->isShared()) { Chris@0: $this->services[$lowerId = strtolower($id)] = $service; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Overrides Symfony\Component\DependencyInjection\ContainerBuilder::set(). Chris@0: * Chris@0: * Drupal's container builder can be used at runtime after compilation, so we Chris@0: * override Symfony's ContainerBuilder's restriction on setting services in a Chris@0: * frozen builder. Chris@0: * Chris@0: * @todo Restrict this to synthetic services only. Ideally, the upstream Chris@0: * ContainerBuilder class should be fixed to allow setting synthetic Chris@0: * services in a frozen builder. Chris@0: */ Chris@0: public function set($id, $service) { Chris@0: if (strtolower($id) !== $id) { Chris@0: throw new \InvalidArgumentException("Service ID names must be lowercase: $id"); Chris@0: } Chris@0: SymfonyContainer::set($id, $service); Chris@0: Chris@0: // Ensure that the _serviceId property is set on synthetic services as well. Chris@0: if (isset($this->services[$id]) && is_object($this->services[$id]) && !isset($this->services[$id]->_serviceId)) { Chris@0: $this->services[$id]->_serviceId = $id; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function register($id, $class = null) { Chris@0: if (strtolower($id) !== $id) { Chris@0: throw new \InvalidArgumentException("Service ID names must be lowercase: $id"); Chris@0: } Chris@0: return parent::register($id, $class); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@14: public function setAlias($alias, $id) { Chris@14: $alias = parent::setAlias($alias, $id); Chris@14: // As of Symfony 3.4 all aliases are private by default. Chris@14: $alias->setPublic(TRUE); Chris@14: return $alias; Chris@14: } Chris@14: Chris@14: /** Chris@14: * {@inheritdoc} Chris@14: */ Chris@14: public function setDefinition($id, Definition $definition) { Chris@14: $definition = parent::setDefinition($id, $definition); Chris@14: // As of Symfony 3.4 all definitions are private by default. Chris@14: // \Symfony\Component\DependencyInjection\Compiler\ResolvePrivatesPassOnly Chris@14: // removes services marked as private from the container even if they are Chris@14: // also marked as public. Drupal requires services that are public to Chris@14: // remain in the container and not be removed. Chris@14: if ($definition->isPublic()) { Chris@14: $definition->setPrivate(FALSE); Chris@14: } Chris@14: return $definition; Chris@14: } Chris@14: Chris@14: /** Chris@14: * {@inheritdoc} Chris@14: */ Chris@0: public function setParameter($name, $value) { Chris@0: if (strtolower($name) !== $name) { Chris@0: throw new \InvalidArgumentException("Parameter names must be lowercase: $name"); Chris@0: } Chris@0: parent::setParameter($name, $value); Chris@0: } Chris@0: Chris@0: /** Chris@0: * A 1to1 copy of parent::callMethod. Chris@14: * Chris@14: * @todo https://www.drupal.org/project/drupal/issues/2937010 Since Symfony Chris@14: * 3.4 this is not a 1to1 copy. Chris@0: */ Chris@14: protected function callMethod($service, $call, array &$inlineServices = array()) { Chris@0: $services = self::getServiceConditionals($call[1]); Chris@0: Chris@0: foreach ($services as $s) { Chris@0: if (!$this->has($s)) { Chris@0: return; Chris@0: } Chris@0: } Chris@0: Chris@0: call_user_func_array(array($service, $call[0]), $this->resolveServices($this->getParameterBag()->resolveValue($call[1]))); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function __sleep() { Chris@0: assert(FALSE, 'The container was serialized.'); Chris@0: return array_keys(get_object_vars($this)); Chris@0: } Chris@0: Chris@0: }