Skip to content

Commit

Permalink
Allow multiple bundle instances to be added to the kernel
Browse files Browse the repository at this point in the history
This commit applies two things:

- The name of the bundle is dynamically changed, because Symfony's
  kernel doesn't allow multiple bundles with the same name
- When the kernel is shutdown, the bundles must be shutdown as well,
  meaning the static identifier must be reset.

One of the known effects before this change was seen when clearing
caches: the kernel could be booted several times during the same
runtime, meaning that the static identifier would change for identical
bundle instances and therefore lead to confusion for the compiled
container, which would not be able to fetch the correct instance.
  • Loading branch information
romm authored and moufmouf committed Apr 10, 2020
1 parent a13207d commit 26017ac
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/InteropServiceProviderBridgeBundle.php
Expand Up @@ -25,6 +25,8 @@ public function __construct(array $serviceProviders = [], $useDiscovery = true)
$this->serviceProviders = $serviceProviders;
$this->useDiscovery = $useDiscovery;
$this->id = self::$count;
$this->name = $this->getName() . $this->id;

self::$count++;
}

Expand All @@ -42,6 +44,16 @@ public function boot()
$this->container->set($registryServiceName, $this->getRegistry($this->container));
}

/**
* When the Kernel shuts down, this bundle's static identifier must be
* reset, otherwise it may lead to incorrect identifier binding for the
* compiled container.
*/
public function shutdown()
{
self::$count = 0;
}

/**
* @param ContainerInterface $container
* @return RegistryInterface
Expand Down

0 comments on commit 26017ac

Please sign in to comment.