-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDualHandReusableBundle.php
60 lines (52 loc) · 1.79 KB
/
DualHandReusableBundle.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace DualHand\ReusableBundle;
use DualHand\ReusableBundle\DependencyInjection\DualHandReusableExtension;
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* Class DualHandReusableBundle.
*/
class DualHandReusableBundle extends Bundle
{
/**
* @param ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
{
parent::build($container);
$this->buildOrmCompilerPass($container);
}
/**
* @return DualHandReusableExtension
*/
public function getContainerExtension()
{
return new DualHandReusableExtension();
}
/**
* @param ContainerBuilder $container
*/
private function buildOrmCompilerPass(ContainerBuilder $container)
{
$arguments = array(
array(
realpath(__DIR__.'/Resources/config/doctrine-model') => 'DualHand\ReusableBundle\Model',
),
'.orm.xml',
);
$locator = new Definition('Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator', $arguments);
$driver = new Definition('Doctrine\ORM\Mapping\Driver\XmlDriver', array($locator));
foreach ($this->getContainerExtension()->getEntitiesOverrides() as $configKey => $entity) {
$container->addCompilerPass(
new DoctrineOrmMappingsPass(
$driver,
array("%DualHand_reusable.$configKey.class%"),
array('DualHand_reusable.model_manager_name'),
"DualHand_reusable.use_default.$configKey"
)
);
}
}
}