Load routes automatically

This commit is contained in:
Julien Fastré 2018-06-05 12:36:14 +02:00
parent cb494f3f4b
commit a1ee85b0c0

View File

@ -6,13 +6,14 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
/** /**
* This is the class that loads and manages your bundle configuration * This is the class that loads and manages your bundle configuration
* *
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
*/ */
class ChillDocStoreExtension extends Extension class ChillDocStoreExtension extends Extension implements PrependExtensionInterface
{ {
/** /**
* {@inheritdoc} * {@inheritdoc}
@ -25,4 +26,21 @@ class ChillDocStoreExtension extends Extension
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml'); $loader->load('services.yml');
} }
public function prepend(ContainerBuilder $container)
{
$this->prependRoute($container);
}
protected function prependRoute(ContainerBuilder $container)
{
//declare routes for task bundle
$container->prependExtensionConfig('chill_main', array(
'routing' => array(
'resources' => array(
'@ChillDocStoreBundle/Resources/config/routing.yml'
)
)
));
}
} }