improves extensibility between bundles

This commit is contained in:
Johannes Schmitt 2011-10-07 21:40:14 +02:00
parent 3d64d8e70f
commit 59e2e97055
3 changed files with 22 additions and 0 deletions

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\HttpKernel\Bundle; namespace Symfony\Component\HttpKernel\Bundle;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\DependencyInjection\ContainerAware; use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\Container;
@ -97,6 +99,13 @@ abstract class Bundle extends ContainerAware implements BundleInterface
} }
} }
/**
* {@inheritDoc}
*/
public function configureContainerExtension(ExtensionInterface $extension)
{
}
/** /**
* Gets the Bundle namespace. * Gets the Bundle namespace.
* *

View File

@ -11,6 +11,8 @@
namespace Symfony\Component\HttpKernel\Bundle; namespace Symfony\Component\HttpKernel\Bundle;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
/** /**
@ -56,6 +58,13 @@ interface BundleInterface
*/ */
function getContainerExtension(); function getContainerExtension();
/**
* Allows the bundle to configure extensions of other bundles.
*
* @param ExtensionInterface $extension
*/
function configureContainerExtension(ExtensionInterface $extension);
/** /**
* Returns the bundle parent name. * Returns the bundle parent name.
* *

View File

@ -628,6 +628,10 @@ abstract class Kernel implements KernelInterface
$bundle->build($container); $bundle->build($container);
if ($extension = $bundle->getContainerExtension()) { if ($extension = $bundle->getContainerExtension()) {
foreach ($this->bundles as $b) {
$b->configureContainerExtension($extension);
}
$container->registerExtension($extension); $container->registerExtension($extension);
$extensions[] = $extension->getAlias(); $extensions[] = $extension->getAlias();
} }