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 Symfony\Component\Config\FileLocator; |
17
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
18
|
|
|
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; |
19
|
|
|
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; |
20
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Simple bus and Doctrine ODM MongoDB bridge bundle extension class. |
24
|
|
|
* |
25
|
|
|
* @author Beñat Espiña <[email protected]> |
26
|
|
|
*/ |
27
|
|
View Code Duplication |
class SimpleBusDoctrineODMMongoDBBridgeExtension extends Extension implements PrependExtensionInterface, SimpleBusTaggerExtension |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* {@inheritdoc} |
31
|
|
|
*/ |
32
|
|
|
public function load(array $configs, ContainerBuilder $container) |
33
|
|
|
{ |
34
|
|
|
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); |
35
|
|
|
|
36
|
|
|
$loader->load('doctrine_odm_mongodb.yml'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* {@inheritdoc} |
41
|
|
|
*/ |
42
|
|
|
public function prepend(ContainerBuilder $container) |
43
|
|
|
{ |
44
|
|
|
$configuration = new Configuration(); |
45
|
|
|
$configs = $container->getExtensionConfig('ben_gor_user'); |
46
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
47
|
|
|
|
48
|
|
|
$container->setParameter('bengor_user.config', $config); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* {@inheritdoc} |
53
|
|
|
*/ |
54
|
|
|
public function addMiddlewareTags(ContainerBuilder $container, $user) |
55
|
|
|
{ |
56
|
|
|
$container->getDefinition( |
57
|
|
|
'bengor_user.simple_bus_bridge_bundle.doctrine_odm_mongodb_transactional_middleware' |
58
|
|
|
)->addTag( |
59
|
|
|
'bengor_user_' . $user . '_command_bus_middleware', ['priority' => '0'] |
60
|
|
|
); |
61
|
|
|
|
62
|
|
|
return $container; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.