Skip to content

Commit

Permalink
[Taxonomy] Move configuration to Bundle Extension.
Browse files Browse the repository at this point in the history
  • Loading branch information
NoUseFreak committed Apr 1, 2015
1 parent 384df7a commit ffef5af
Showing 1 changed file with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;

Expand All @@ -12,7 +13,7 @@
*
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/
class ClasticTaxonomyExtension extends Extension
class ClasticTaxonomyExtension extends Extension implements PrependExtensionInterface
{
/**
* {@inheritdoc}
Expand All @@ -25,4 +26,37 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.xml');
}

/**
* Allow an extension to prepend the extension configurations.
*
* @param ContainerBuilder $container
*/
public function prepend(ContainerBuilder $container)
{
$bundles = $container->getParameter('kernel.bundles');

if (true === isset($bundles['StofDoctrineExtensionsBundle'])) {
$this->configureStofDoctrineExtensionsBundle($container);
}
}

/**
* @param ContainerBuilder $container The service container
*
* @return void
*/
protected function configureStofDoctrineExtensionsBundle(ContainerBuilder $container)
{
foreach (array_keys($container->getExtensions()) as $name) {
switch ($name) {
case 'stof_doctrine_extensions':
$container->prependExtensionConfig(
$name,
array('orm' => array('default' => array('tree' => true)))
);
break;
}
}
}
}

0 comments on commit ffef5af

Please sign in to comment.