-
-
Notifications
You must be signed in to change notification settings - Fork 447
/
BundleConfigurationBuilder.php
88 lines (70 loc) · 1.89 KB
/
BundleConfigurationBuilder.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
namespace Doctrine\Bundle\DoctrineBundle\Tests\Builder;
class BundleConfigurationBuilder
{
/** @var array */
private $configuration;
public static function createBuilder()
{
return new self();
}
public static function createBuilderWithBaseValues()
{
$builder = new self();
$builder->addBaseConnection();
$builder->addBaseEntityManager();
return $builder;
}
public function addBaseConnection() : self
{
$this->addConnection([
'connections' => [
'default' => ['password' => 'foo'],
],
]);
return $this;
}
public function addBaseEntityManager() : self
{
$this->addEntityManager([
'default_entity_manager' => 'default',
'entity_managers' => [
'default' => [
'mappings' => [
'YamlBundle' => [],
],
],
],
]);
return $this;
}
public function addBaseSecondLevelCache() : self
{
$this->addSecondLevelCache([
'region_cache_driver' => ['type' => 'pool', 'pool' => 'my_pool'],
'regions' => [
'hour_region' => ['lifetime' => 3600],
],
]);
return $this;
}
public function addConnection($config) : self
{
$this->configuration['dbal'] = $config;
return $this;
}
public function addEntityManager($config) : self
{
$this->configuration['orm'] = $config;
return $this;
}
public function addSecondLevelCache($config, $manager = 'default') : self
{
$this->configuration['orm']['entity_managers'][$manager]['second_level_cache'] = $config;
return $this;
}
public function build() : array
{
return $this->configuration;
}
}