Skip to content

Commit

Permalink
Merge 28546c5 into 71d782a
Browse files Browse the repository at this point in the history
  • Loading branch information
magarzon committed Jul 31, 2015
2 parents 71d782a + 28546c5 commit 5932b57
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/BundlePlugin.php
Expand Up @@ -55,4 +55,13 @@ public function build(ContainerBuilder $container);
* @return void
*/
public function boot(ContainerInterface $container);

/**
* When the container is generated for the first time, this method is called
* to give an opportunity to prepend configuration for this or other bundles
*
* @param ContainerInterface $container
* @return void
*/
public function prepend(ContainerBuilder $container);
}
15 changes: 14 additions & 1 deletion src/ExtensionWithPlugins.php
Expand Up @@ -3,9 +3,10 @@
namespace Matthias\BundlePlugins;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

final class ExtensionWithPlugins extends Extension
final class ExtensionWithPlugins extends Extension implements PrependExtensionInterface
{
/**
* @var string
Expand Down Expand Up @@ -86,4 +87,16 @@ private function pluginConfiguration(BundlePlugin $plugin, array $processedConfi

return $processedConfiguration[$plugin->name()];
}

/**
* Allow an extension to prepend the extension configurations.
*
* @param ContainerBuilder $container
*/
public function prepend(ContainerBuilder $container)
{
foreach ($this->registeredPlugins as $plugin) {
$plugin->prepend($container);
}
}
}
9 changes: 9 additions & 0 deletions src/SimpleBundlePlugin.php
Expand Up @@ -37,4 +37,13 @@ public function build(ContainerBuilder $container)
public function boot(ContainerInterface $container)
{
}

/**
* Override this method if your plugin needs to prepend configuration
*
* @inheritdoc
*/
public function prepend(ContainerBuilder $container)
{
}
}
4 changes: 4 additions & 0 deletions test/BarPlugin.php
Expand Up @@ -40,4 +40,8 @@ public function boot(ContainerInterface $container)
{
$container->get('bar.boot')->call();
}

public function prepend(ContainerBuilder $container)
{
}
}
4 changes: 4 additions & 0 deletions test/CorePlugin.php
Expand Up @@ -42,4 +42,8 @@ public function boot(ContainerInterface $container)
{
$container->get('core.boot')->call();
}

public function prepend(ContainerBuilder $container)
{
}
}
4 changes: 4 additions & 0 deletions test/FooPlugin.php
Expand Up @@ -40,4 +40,8 @@ public function boot(ContainerInterface $container)
{
$container->get('foo.boot')->call();
}

public function prepend(ContainerBuilder $container)
{
}
}

0 comments on commit 5932b57

Please sign in to comment.