-
Notifications
You must be signed in to change notification settings - Fork 2
/
OrkestraApplicationBundle.php
63 lines (54 loc) · 2.32 KB
/
OrkestraApplicationBundle.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
57
58
59
60
61
62
63
<?php
/*
* This file is part of the OrkestraApplicationBundle package.
*
* Copyright (c) Orkestra Community
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
namespace Orkestra\Bundle\ApplicationBundle;
use Doctrine\DBAL\Types\Type;
use Orkestra\Bundle\ApplicationBundle\DependencyInjection\Compiler\ModifyServiceDefinitionsPass;
use Orkestra\Bundle\ApplicationBundle\DependencyInjection\Compiler\RegisterFormTypesPass;
use Orkestra\Bundle\ApplicationBundle\DependencyInjection\Compiler\RegisterWorkersPass;
use Orkestra\Common\DbalType\EncryptedStringType;
use Orkestra\Common\Type\Date;
use Orkestra\Common\Type\DateTime;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class OrkestraApplicationBundle extends Bundle
{
const VERSION = '1.0.0-DEV';
/**
* {@inheritDoc}
*/
public function boot()
{
Type::overrideType('datetime', 'Orkestra\Common\DbalType\DateTimeType');
Type::overrideType('date', 'Orkestra\Common\DbalType\DateType');
Type::overrideType('time', 'Orkestra\Common\DbalType\TimeType');
if (!Type::hasType('encrypted_string')) {
Type::addType('encrypted_string', 'Orkestra\Common\DbalType\EncryptedStringType');
} elseif (!(Type::getType('encrypted_string') instanceof EncryptedStringType)) {
throw new \UnexpectedValueException('Type encrypted_string must be instance of Orkestra\Common\DbalType\EncryptedStringType');
}
$encryptedStringType = Type::getType('encrypted_string');
$encryptedStringType->setKey($this->container->getParameter('secret'));
// Set up date related settings
$defaultTimezone = new \DateTimeZone(date_default_timezone_get());
DateTime::setServerTimezone($defaultTimezone);
DateTime::setUserTimezone($defaultTimezone);
DateTime::setDefaultFormat('Y-m-d H:i:s');
Date::setDefaultFormat('Y-m-d');
}
/**
* {@inheritDoc}
*/
public function build(ContainerBuilder $container)
{
$container->addCompilerPass(new ModifyServiceDefinitionsPass());
$container->addCompilerPass(new RegisterFormTypesPass());
$container->addCompilerPass(new RegisterWorkersPass());
}
}