This repository has been archived by the owner on Jun 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HarmonyCoreBundle.php
56 lines (49 loc) · 1.85 KB
/
HarmonyCoreBundle.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
<?php
namespace Harmony\Bundle\CoreBundle;
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass;
use Harmony\Bundle\CoreBundle\DependencyInjection\HarmonyCoreExtension;
use LogicException;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use function class_exists;
use function realpath;
/**
* Class HarmonyCoreBundle
*
* @package Harmony\Bundle\CoreBundle
*/
class HarmonyCoreBundle extends Bundle
{
/** Constants */
const VERSION = '0.1';
const NAME = 'HarmonyCMS';
/**
* Builds the bundle.
* It is only ever called once when the cache is empty.
*
* @param ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
{
// get all bundles
$bundles = $container->getParameter('kernel.bundles');
$mappings = [realpath(__DIR__ . '/Resources/config/doctrine-mapping') => 'Harmony\Bundle\CoreBundle\Model'];
if (class_exists(DoctrineMongoDBMappingsPass::class) && isset($bundles['DoctrineMongoDBBundle'])) {
$container->addCompilerPass(DoctrineMongoDBMappingsPass::createXmlMappingDriver($mappings, []));
} elseif (class_exists(DoctrineOrmMappingsPass::class) && isset($bundles['DoctrineBundle'])) {
$container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings));
}
}
/**
* Returns the bundle's container extension.
*
* @return ExtensionInterface|null The container extension
* @throws LogicException
*/
public function getContainerExtension(): ExtensionInterface
{
return new HarmonyCoreExtension();
}
}