-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnhavoRoutingBundle.php
40 lines (33 loc) · 1.4 KB
/
EnhavoRoutingBundle.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Enhavo\Bundle\RoutingBundle;
use Doctrine\ORM\Mapping\Driver\XmlDriver;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\Definition;
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
use Doctrine\Persistence\Mapping\Driver\DefaultFileLocator;
use Enhavo\Bundle\AppBundle\Type\TypeCompilerPass;
class EnhavoRoutingBundle extends Bundle
{
public function build(ContainerBuilder $container): void
{
$container->addCompilerPass($this->buildRouteCompilerPass());
$container->addCompilerPass(
new TypeCompilerPass('enhavo_routing.auto_generator.route_generator_collector', 'enhavo_route.generator')
);
$container->addCompilerPass(
new TypeCompilerPass('enhavo_routing.router.strategy_collector', 'enhavo_route.strategy')
);
}
private function buildRouteCompilerPass()
{
$arguments = array(array(realpath(__DIR__.'/Resources/config/doctrine-route')), '.orm.xml');
$locator = new Definition(DefaultFileLocator::class, $arguments);
$driver = new Definition(XmlDriver::class, array($locator));
return new DoctrineOrmMappingsPass(
$driver,
['Symfony\Component\Routing'],
['doctrine.default_entity_manager']
);
}
}