-
Notifications
You must be signed in to change notification settings - Fork 0
/
NyroDevNyroCmsBundle.php
37 lines (32 loc) · 1.7 KB
/
NyroDevNyroCmsBundle.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
<?php
namespace NyroDev\NyroCmsBundle;
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
use Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass;
use NyroDev\NyroCmsBundle\DependencyInjection\Compiler\DbPass;
use NyroDev\NyroCmsBundle\DependencyInjection\Compiler\ValidationPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\HttpKernel\KernelInterface;
class NyroDevNyroCmsBundle extends Bundle
{
public function build(ContainerBuilder $container): void
{
parent::build($container);
$container->addCompilerPass(new ValidationPass());
$container->addCompilerPass(new DbPass());
// Kernel is not build yet
// $pathMapping = $container->get(KernelInterface::class)->getProjectDir().'/config/nyrocms-doctrine-mapping';
$pathMapping = $container->getParameter('kernel.project_dir').'/config/nyrocms-doctrine-mapping';
if (file_exists($pathMapping)) {
$mappings = [
$pathMapping => 'NyroDev\NyroCmsBundle\Model',
];
if (class_exists('Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass')) {
$container->addCompilerPass(DoctrineOrmMappingsPass::createXmlMappingDriver($mappings, ['nyrocms.model_manager_name']));
}
if (class_exists('Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler\DoctrineMongoDBMappingsPass')) {
$container->addCompilerPass(DoctrineMongoDBMappingsPass::createXmlMappingDriver($mappings, ['nyrocms.model_manager_name']));
}
}
}
}