Container.php 777 B

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