forked from fre5h/DoctrineEnumBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFreshDoctrineEnumBundle.php
45 lines (39 loc) · 1.36 KB
/
FreshDoctrineEnumBundle.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
<?php
/*
* This file is part of the FreshDoctrineEnumBundle
*
* (c) Artem Henvald <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Fresh\DoctrineEnumBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
/**
* FreshDoctrineEnumBundle.
*
* @author Artem Henvald <[email protected]>
*/
class FreshDoctrineEnumBundle extends Bundle
{
/**
* {@inheritdoc}
*
* @throws \Doctrine\DBAL\DBALException
* @throws \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException
* @throws \Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException
*/
public function boot(): void
{
parent::boot();
$doctrine = $this->container->get('doctrine');
/** @var \Doctrine\DBAL\Connection $connection */
foreach ($doctrine->getConnections() as $connection) {
/** @var \Doctrine\DBAL\Platforms\AbstractPlatform $databasePlatform */
$databasePlatform = $connection->getDatabasePlatform();
if (!$databasePlatform->hasDoctrineTypeMappingFor('enum') || 'string' !== $databasePlatform->getDoctrineTypeMapping('enum')) {
$databasePlatform->registerDoctrineTypeMapping('enum', 'string');
}
}
}
}