From Walloping Tortoise, 9 Years ago, written in Plain Text.
Embed
  1.  class ContainerBuilder extends SymfonyContainerBuilder {
  2.  
  3. +  protected $explicitlySet = [];
  4. +
  5.    /**
  6.     * {@inheritdoc}
  7.     */
  8. @@ -44,6 +48,7 @@ public function set($id, $service, $scope = self::SCOPE_CONTAINER) {
  9.      if (strtolower($id) !== $id) {
  10.        throw new \InvalidArgumentException("Service ID names must be lowercase: $id");
  11.      }
  12. +    $this->explicitlySet[$id] = TRUE;
  13.      SymfonyContainer::set($id, $service, $scope);
  14.  
  15.      // Ensure that the _serviceId property is set on synthetic services as well.
  16. @@ -100,6 +105,17 @@ private function synchronize($id) {
  17.    }
  18.  
  19.    /**
  20. +   * {@inheritdoc}
  21. +   */
  22. +  public function compile() {
  23. +    parent::compile();
  24. +    // Remove all non-synthetic services set by compiler passes. For example,
  25. +    // cache bins are forced to NulLBackend before the ListCacheBinsPass and
  26. +    // so cache services might got stored as NullBackend.
  27. +    $this->services = array_intersect_key($this->services, $this->explicitlySet);
  28. +  }
  29. +
  30. +  /**
  31.     * A 1to1 copy of parent::callMethod.
  32.     */
  33.    protected function callMethod($service, $call) {
  34.