4a491225b0cc2813bfc9f0d193377a7bcdc12460
[yaffs-website] / web / core / lib / Drupal / Core / DependencyInjection / Container.php
1 <?php
2
3 namespace Drupal\Core\DependencyInjection;
4
5 use Drupal\Component\DependencyInjection\Container as DrupalContainer;
6 use Symfony\Component\DependencyInjection\ContainerInterface;
7
8 /**
9  * Extends the Drupal container to set the service ID on the created object.
10  */
11 class Container extends DrupalContainer {
12
13   /**
14    * {@inheritdoc}
15    */
16   public function set($id, $service, $scope = ContainerInterface::SCOPE_CONTAINER) {
17     parent::set($id, $service, $scope);
18
19     // Ensure that the _serviceId property is set on synthetic services as well.
20     if (isset($this->services[$id]) && is_object($this->services[$id]) && !isset($this->services[$id]->_serviceId)) {
21       $this->services[$id]->_serviceId = $id;
22     }
23   }
24
25   /**
26    * {@inheritdoc}
27    */
28   public function __sleep() {
29     assert(FALSE, 'The container was serialized.');
30     return array_keys(get_object_vars($this));
31   }
32
33 }