This repository has been archived by the owner on Oct 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBundle.php
executable file
·52 lines (46 loc) · 1.84 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
<?php
namespace Bundle\DoctrineMongoDBBundle;
use Symfony\Foundation\Bundle\Bundle as BaseBundle,
Symfony\Components\DependencyInjection\ContainerInterface,
Symfony\Components\DependencyInjection\Loader\Loader,
Bundle\DoctrineMongoDBBundle\DependencyInjection\MongoDBExtension;
/**
* Description of Bundle
*
* @author Bulat Shakirzyanov <bulat@theopenskyproject.com>
*/
class Bundle extends BaseBundle
{
public function buildContainer(ContainerInterface $container)
{
$kernelBundleDirs = $container->getParameter('kernel.bundle_dirs');
$kernelBundles = $container->getParameter('kernel.bundles');
$appName = $container->getParameter('kernel.name');
$cacheDir = $container->getParameter('kernel.cache_dir');
Loader::registerExtension(
new MongoDBExtension($kernelBundleDirs, $kernelBundles, $appName, $cacheDir)
);
$metadataDirs = array();
$documentDirs = array();
$bundleDirs = $kernelBundleDirs;
foreach ($kernelBundles 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[] = realpath($dir);
}
if (is_dir($dir = $bundleDirs[$namespace].'/'.$class))
{
$documentDirs[] = realpath($dir);
}
}
}
$container->setParameter('doctrine.odm.metadata_driver.mapping_dirs', $metadataDirs);
$container->setParameter('doctrine.odm.document_dirs', $documentDirs);
}
}