Chris@0: setResourceTracking(FALSE); Chris@0: parent::__construct($parameterBag); 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@0: * {@inheritdoc} Chris@0: */ Chris@0: protected function shareService(Definition $definition, $service, $id) 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@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@0: */ Chris@0: protected function callMethod($service, $call) { 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: }