1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Hgraca\DoctrineTestDbRegenerationBundle\DependencyInjection; |
6
|
|
|
|
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
8
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
9
|
|
|
|
10
|
|
|
class HgracaDoctrineTestDbRegenerationExtension extends Extension |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var array |
14
|
|
|
*/ |
15
|
|
|
private $processedConfig; |
16
|
|
|
|
17
|
10 |
|
public function load(array $configs, ContainerBuilder $containerBuilder): void |
18
|
|
|
{ |
19
|
10 |
|
$configuration = new Configuration(); |
20
|
10 |
|
$this->processedConfig = $this->processConfiguration($configuration, $configs); |
21
|
|
|
|
22
|
10 |
|
$containerBuilder->setParameter( |
23
|
10 |
|
Configuration::ROOT . '.' . Configuration::FIXTURES_LOADER_SERVICE_ID, |
24
|
10 |
|
$this->getFixturesLoaderServiceId() |
25
|
|
|
); |
26
|
|
|
|
27
|
10 |
|
$containerBuilder->setParameter( |
28
|
10 |
|
Configuration::ROOT . '.' . Configuration::DOCTRINE_SERVICE_ID, |
29
|
10 |
|
$this->getDoctrineServiceId() |
30
|
|
|
); |
31
|
|
|
|
32
|
10 |
|
$containerBuilder->setParameter( |
33
|
10 |
|
Configuration::ROOT . '.' . Configuration::TEST_DB_BKP_PATH, |
34
|
10 |
|
$this->getTestDbBkpPath() |
35
|
|
|
); |
36
|
10 |
|
} |
37
|
|
|
|
38
|
10 |
|
public function getFixturesLoaderServiceId(): string |
39
|
|
|
{ |
40
|
10 |
|
return $this->processedConfig[Configuration::FIXTURES_LOADER_SERVICE_ID]; |
41
|
|
|
} |
42
|
|
|
|
43
|
10 |
|
public function getDoctrineServiceId(): string |
44
|
|
|
{ |
45
|
10 |
|
return $this->processedConfig[Configuration::DOCTRINE_SERVICE_ID]; |
46
|
|
|
} |
47
|
|
|
|
48
|
10 |
|
public function getTestDbBkpPath(): string |
49
|
|
|
{ |
50
|
10 |
|
return $this->processedConfig[Configuration::TEST_DB_BKP_PATH]; |
51
|
|
|
} |
52
|
|
|
|
53
|
8 |
|
private function getExtraServiceList(): array |
54
|
|
|
{ |
55
|
8 |
|
return $this->processedConfig[Configuration::EXTRA_SERVICE_LIST] ?? []; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return string[] |
60
|
|
|
*/ |
61
|
8 |
|
public function getServicesIdList(): array |
62
|
|
|
{ |
63
|
8 |
|
return array_merge( |
64
|
|
|
[ |
65
|
8 |
|
$this->getFixturesLoaderServiceId(), |
66
|
8 |
|
$this->getDoctrineServiceId(), |
67
|
|
|
], |
68
|
8 |
|
$this->getExtraServiceList() |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|