/
Bundle.php
57 lines (51 loc) · 1.83 KB
/
Bundle.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
<?php
namespace Symfony\Framework\DoctrineBundle;
use Symfony\Foundation\Bundle\Bundle as BaseBundle;
use Symfony\Components\DependencyInjection\ContainerInterface;
use Symfony\Components\DependencyInjection\Loader\Loader;
use Symfony\Components\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Framework\DoctrineBundle\DependencyInjection\DoctrineExtension;
/*
* This file is part of the symfony framework.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
/**
*
*
* @package symfony
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
* @author Jonathan H. Wage <jonwage@gmail.com>
*/
class Bundle extends BaseBundle
{
public function buildContainer(ContainerInterface $container)
{
Loader::registerExtension(new DoctrineExtension($container->getParameter('kernel.bundle_dirs'), $container->getParameter('kernel.bundles')));
$metadataDirs = array();
$entityDirs = array();
$bundleDirs = $container->getParameter('kernel.bundle_dirs');
foreach ($container->getParameter('kernel.bundles') as $className)
{
$tmp = dirname(str_replace('\\', '/', $className));
$namespace = str_replace('/', '\\', dirname($tmp));
$class = basename($tmp);
if (isset($bundleDirs[$namespace]))
{
if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Resources/config/doctrine/metadata'))
{
$metadataDirs[] = $dir;
}
if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Entities'))
{
$entityDirs[] = $dir;
}
}
}
$container->setParameter('doctrine.orm.metadata_driver.mapping_dirs', $metadataDirs);
$container->setParameter('doctrine.orm.entity_dirs', $entityDirs);
}
}