1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the BenGorUser package. |
5
|
|
|
* |
6
|
|
|
* (c) Beñat Espiña <[email protected]> |
7
|
|
|
* (c) Gorka Laucirica <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace BenGorUser\SimpleBusBridgeBundle\DependencyInjection; |
14
|
|
|
|
15
|
|
|
use BenGorUser\UserBundle\DependencyInjection\Configuration; |
16
|
|
|
use SimpleBus\Message\Handler\DelegatesToMessageHandlerMiddleware; |
17
|
|
|
use SimpleBus\Message\Recorder\HandlesRecordedMessagesMiddleware; |
18
|
|
|
use SimpleBus\Message\Subscriber\NotifiesMessageSubscribersMiddleware; |
19
|
|
|
use Symfony\Component\Config\FileLocator; |
20
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
21
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
22
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
23
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
24
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Simple bus and Doctrine ORM bridge bundle extension class. |
28
|
|
|
* |
29
|
|
|
* @author Beñat Espiña <[email protected]> |
30
|
|
|
*/ |
31
|
|
|
class SimpleBusDoctrineORMBridgeExtension extends Extension implements PrependExtensionInterface, SimpleBusTaggerExtension |
|
|
|
|
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* {@inheritdoc} |
35
|
|
|
*/ |
36
|
|
|
public function load(array $configs, ContainerBuilder $container) |
37
|
|
|
{ |
38
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
39
|
|
|
|
40
|
|
|
$loader->load('doctrine_orm.yml'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* {@inheritdoc} |
45
|
|
|
*/ |
46
|
|
View Code Duplication |
public function prepend(ContainerBuilder $container) |
|
|
|
|
47
|
|
|
{ |
48
|
|
|
$configuration = new Configuration(); |
49
|
|
|
$configs = $container->getExtensionConfig('ben_gor_user'); |
50
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
51
|
|
|
|
52
|
|
|
$container->setParameter('bengor_user.config', $config); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* {@inheritdoc} |
57
|
|
|
*/ |
58
|
|
|
public function addMiddlewareTags(ContainerBuilder $container, $user) |
59
|
|
|
{ |
60
|
|
|
$container->getDefinition( |
61
|
|
|
'bengor_user.simple_bus_bridge_bundle.doctrine_orm_transactional_middleware' |
62
|
|
|
)->addTag( |
63
|
|
|
'bengor_user_' . $user . '_command_bus_middleware', ['priority' => '0'] |
64
|
|
|
); |
65
|
|
|
|
66
|
|
|
return $container; |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.