protected function Kernel::initializeBundles in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/http-kernel/Kernel.php \Symfony\Component\HttpKernel\Kernel::initializeBundles()
Initializes the data structures related to the bundle management.
- the bundles property maps a bundle name to the bundle instance,
- the bundleMap property maps a bundle name to the bundle inheritance hierarchy (most derived bundle first).
Throws
\LogicException if two bundles share a common name
\LogicException if a bundle tries to extend a non-registered bundle
\LogicException if a bundle tries to extend itself
\LogicException if two bundles extend the same ancestor
1 call to Kernel::initializeBundles()
- Kernel::boot in vendor/
symfony/ http-kernel/ Kernel.php - Boots the current kernel.
File
- vendor/
symfony/ http-kernel/ Kernel.php, line 422
Class
- Kernel
- The Kernel is the heart of the Symfony system.
Namespace
Symfony\Component\HttpKernelCode
protected function initializeBundles() {
// init bundles
$this->bundles = array();
$topMostBundles = array();
$directChildren = array();
foreach ($this
->registerBundles() as $bundle) {
$name = $bundle
->getName();
if (isset($this->bundles[$name])) {
throw new \LogicException(sprintf('Trying to register two bundles with the same name "%s"', $name));
}
$this->bundles[$name] = $bundle;
if ($parentName = $bundle
->getParent()) {
if (isset($directChildren[$parentName])) {
throw new \LogicException(sprintf('Bundle "%s" is directly extended by two bundles "%s" and "%s".', $parentName, $name, $directChildren[$parentName]));
}
if ($parentName == $name) {
throw new \LogicException(sprintf('Bundle "%s" can not extend itself.', $name));
}
$directChildren[$parentName] = $name;
}
else {
$topMostBundles[$name] = $bundle;
}
}
// look for orphans
if (!empty($directChildren) && count($diff = array_diff_key($directChildren, $this->bundles))) {
$diff = array_keys($diff);
throw new \LogicException(sprintf('Bundle "%s" extends bundle "%s", which is not registered.', $directChildren[$diff[0]], $diff[0]));
}
// inheritance
$this->bundleMap = array();
foreach ($topMostBundles as $name => $bundle) {
$bundleMap = array(
$bundle,
);
$hierarchy = array(
$name,
);
while (isset($directChildren[$name])) {
$name = $directChildren[$name];
array_unshift($bundleMap, $this->bundles[$name]);
$hierarchy[] = $name;
}
foreach ($hierarchy as $bundle) {
$this->bundleMap[$bundle] = $bundleMap;
array_pop($bundleMap);
}
}
}