forked from TheBigBrainsCompany/TbbcMoneyBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTbbcMoneyBundle.php
44 lines (35 loc) · 1.55 KB
/
TbbcMoneyBundle.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
<?php
namespace Tbbc\MoneyBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Doctrine\DBAL\Types\Type;
use Tbbc\MoneyBundle\DependencyInjection\Compiler\PairHistoryCompilerPass;
use Tbbc\MoneyBundle\DependencyInjection\Compiler\RatioProviderCompilerPass;
use Tbbc\MoneyBundle\DependencyInjection\Compiler\StorageCompilerPass;
use Tbbc\MoneyBundle\Type\MoneyType;
class TbbcMoneyBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new StorageCompilerPass());
$container->addCompilerPass(new PairHistoryCompilerPass());
$container->addCompilerPass(new RatioProviderCompilerPass());
}
public function boot()
{
parent::boot();
if($this->container->hasParameter('doctrine.entity_managers')){
if(!Type::hasType(MoneyType::NAME)) {
Type::addType(MoneyType::NAME, 'Tbbc\MoneyBundle\Type\MoneyType');
}
$entityManagerNameList = $this->container->getParameter('doctrine.entity_managers');
foreach($entityManagerNameList as $entityManagerName) {
$em = $this->container->get($entityManagerName);
if (!$em->getConnection()->getDatabasePlatform()->hasDoctrineTypeMappingFor(MoneyType::NAME)) {
$em->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping(MoneyType::NAME, MoneyType::NAME);
}
}
}
}
}