-
Notifications
You must be signed in to change notification settings - Fork 1
/
YoushidoDoctrineExtensionBundle.php
49 lines (41 loc) · 1.85 KB
/
YoushidoDoctrineExtensionBundle.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
<?php
namespace Youshido\DoctrineExtensionBundle;
use Doctrine\DBAL\Types\Type;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Youshido\DoctrineExtensionBundle\AesEncrypt\Type\AesEncryptedType;
use Youshido\DoctrineExtensionBundle\Scopable\Filter\ScopableFilter;
class YoushidoDoctrineExtensionBundle extends Bundle
{
public function boot()
{
parent::boot();
$config = $this->container->getParameter('youshido_doctrine_extension_config');
$em = $this->container
->get('doctrine.orm.entity_manager');
// scopable
if (!empty($config[ScopableFilter::NAME]) && $config[ScopableFilter::NAME]) {
// check for cache:clear command
if (!$em->getFilters()->has(ScopableFilter::NAME)) {
$em->getConfiguration()
->addFilter(ScopableFilter::NAME, 'Youshido\DoctrineExtensionBundle\Scopable\Filter\ScopableFilter');
$em->getFilters()->enable(ScopableFilter::NAME);
}
}
// $configuration
// ->setDefaultQueryHint(
// Query::HINT_CUSTOM_OUTPUT_WALKER,
// 'Youshido\DoctrineExtensionBundle\AesEncrypt\Walker\EncryptWalker'
// );
// aes_encrypt
if (!empty($config[AesEncryptedType::NAME]) && $config[AesEncryptedType::NAME]) {
// check for cache:clear command
if (!Type::hasType(AesEncryptedType::NAME)) {
Type::addType(AesEncryptedType::NAME, 'Youshido\DoctrineExtensionBundle\AesEncrypt\Type\AesEncryptedType');
$this->container->get('aes_encrypt_service')->setKey($config[AesEncryptedType::NAME]['key']);
$em->getConnection()
->getDatabasePlatform()
->registerDoctrineTypeMapping(AesEncryptedType::NAME, 'aes_encrypted');
}
}
}
}