1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This file is part of the xAPI package. |
7
|
|
|
* |
8
|
|
|
* (c) Christian Flothmann <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace XApi\LrsBundle\DependencyInjection; |
15
|
|
|
|
16
|
|
|
use Symfony\Component\Config\FileLocator; |
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
18
|
|
|
use Symfony\Component\DependencyInjection\Extension\Extension; |
19
|
|
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @author Christian Flothmann <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
final class XApiLrsExtension extends Extension |
25
|
|
|
{ |
26
|
|
|
public function load(array $configs, ContainerBuilder $container): void |
27
|
|
|
{ |
28
|
|
|
$configuration = new Configuration(); |
29
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
30
|
|
|
|
31
|
|
|
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
32
|
|
|
|
33
|
|
|
$loader->load('controller.xml'); |
34
|
|
|
$loader->load('event_listener.xml'); |
35
|
|
|
$loader->load('factory.xml'); |
36
|
|
|
$loader->load('serializer.xml'); |
37
|
|
|
|
38
|
|
|
switch ($config['type']) { |
39
|
|
|
case 'in_memory': |
40
|
|
|
break; |
41
|
|
|
|
42
|
|
|
case 'mongodb': |
43
|
|
|
$loader->load('doctrine.xml'); |
44
|
|
|
$loader->load('mongodb.xml'); |
45
|
|
|
|
46
|
|
|
$container->setAlias('xapi_lrs.doctrine.object_manager', $config['object_manager_service']); |
47
|
|
|
$container->setAlias('xapi_lrs.repository.statement', 'xapi_lrs.repository.statement.doctrine'); |
48
|
|
|
|
49
|
|
|
break; |
50
|
|
|
|
51
|
|
|
case 'orm': |
52
|
|
|
$loader->load('doctrine.xml'); |
53
|
|
|
$loader->load('orm.xml'); |
54
|
|
|
|
55
|
|
|
$container->setAlias('xapi_lrs.doctrine.object_manager', $config['object_manager_service']); |
56
|
|
|
$container->setAlias('xapi_lrs.repository.statement', 'xapi_lrs.repository.statement.doctrine'); |
57
|
|
|
|
58
|
|
|
break; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getAlias() |
63
|
|
|
{ |
64
|
|
|
return 'xapi_lrs'; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|