10000 [WIP][HttpKernel] Expose bundle hierarchy/metadata as a service by ro0NL · Pull Request #19594 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[WIP][HttpKernel] Expose bundle hierarchy/metadata as a service #19594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000
Prev Previous commit
try BundleMetadata[] as a service
  • Loading branch information
ro0NL committed Aug 11, 2016
commit 0aa08ea84b27547309e643de43ca28c80612673a
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public function process(ContainerBuilder $container)
$tmpContainer = new ContainerBuilder($container->getParameterBag());
$tmpContainer->setResourceTracking($container->isTrackingResources());
$tmpContainer->addObjectResource($extension);
if ($container->has('kernel.bundles')) {
$tmpContainer->set('kernel.bundles', $container->get('kernel.bundles'));
}

foreach ($exprLangProviders as $provider) {
$tmpContainer->addExpressionLanguageProvider($provider);
Expand Down
37 changes: 20 additions & 17 deletions src/Symfony/Component/HttpKernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,22 +507,9 @@ protected function initializeContainer()
protected function getKernelParameters()
{
$bundles = array();
$bundleHierarchy = array();
$numBundles = count($this->bundles);
$numProcessedBundles = 0;
do {
foreach ($this->bundles as $name => $bundle) {
$parent = $bundle->getParent();
if (null !== $parent && !isset($bundles[$parent])) {
continue;
}
if (!isset($bundles[$name])) {
$bundles[$name] = get_class($bundle);
$bundleHierarchy[$name] = new BundleMetadata($name, $bundle->getNamespace(), $bundles[$name], $bundle->getPath(), isset($bundleHierarchy[$parent]) ? $bundleHierarchy[$parent] : null);
++$numProcessedBundles;
}
}
} while ($numProcessedBundles < $numBundles);
foreach ($this->bundles as $name => $bundle) {
$bundles[$name] = get_class($bundle);
}

return array_merge(
array(
Expand All @@ -533,7 +520,6 @@ protected function getKernelParameters()
'kernel.cache_dir' => realpath($this->getCacheDir()) ?: $this->getCacheDir(),
'kernel.logs_dir' => realpath($this->getLogDir()) ?: $this->getLogDir(),
'kernel.bundles' => $bundles,
'kernel.bundle_hierarchy' => $bundleHierarchy,
'kernel.charset' => $this->getCharset(),
'kernel.container_class' => $this->getContainerClass(),
),
Expand Down Expand Up @@ -600,6 +586,23 @@ protected function buildContainer()
*/
protected function prepareContainer(ContainerBuilder $container)
{
$bundleMetadata = array();
$numBundles = count($this->bundles);
$numProcessedBundles = 0;
do {
foreach ($this->bundles as $name => $bundle) {
$parent = $bundle->getParent();
if (null !== $parent && !isset($bundleMetadata[$parent])) {
continue;
}
if (!isset($bundleMetadata[$name])) {
$bundleMetadata[$name] = new BundleMetadata($name, $bundle->getNamespace(), get_class($bundle), $bundle->getPath(), isset($bundleMetadata[$parent]) ? $bundleMetadata[$parent] : null);
++$numProcessedBundles;
}
}
} while ($numProcessedBundles < $numBundles);
$container->set('kernel.bundles', new \ArrayIterator($bundleMetadata));

$extensions = array();
foreach ($this->bundles as $bundle) {
if ($extension = $bundle->getContainerExtension()) {
Expand Down
0