1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Freshcells\SoapClientBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Freshcells\SoapClientBundle\Plugin\AnonymizerLogPlugin; |
6
|
|
|
use Freshcells\SoapClientBundle\Plugin\LogPlugin; |
7
|
|
|
use Symfony\Component\Config\FileLocator; |
8
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
9
|
|
|
use Symfony\Component\DependencyInjection\Loader; |
10
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
11
|
|
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
12
|
|
|
|
13
|
|
|
class FreshcellsSoapClientExtension extends Extension |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* {@inheritDoc} |
17
|
3 |
|
*/ |
18
|
|
|
public function load(array $configs, ContainerBuilder $container) |
19
|
3 |
|
{ |
20
|
3 |
|
$configuration = new Configuration(); |
21
|
|
|
$config = $this->processConfiguration($configuration, $configs); |
22
|
3 |
|
|
23
|
3 |
|
foreach ($config as $key => $configVal) { |
24
|
3 |
|
$container->setParameter( |
25
|
3 |
|
'freshcells_soap_client".'.$key, |
26
|
|
|
$configVal |
27
|
|
|
); |
28
|
|
|
} |
29
|
3 |
|
|
30
|
3 |
|
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); |
31
|
|
|
$loader->load('services.xml'); |
32
|
3 |
|
|
33
|
3 |
|
if ($config['enable_profiler']) { |
34
|
|
|
$loader->load('data_collector.xml'); |
35
|
|
|
} |
36
|
3 |
|
|
37
|
3 |
|
if ($config['logger']) { |
38
|
3 |
|
$subscriber = $container->getDefinition(LogPlugin::class); |
39
|
3 |
|
if (isset($config['anonymize_logs']['elements']) && isset($config['anonymize_logs']['attributes'])) { |
40
|
|
|
$subscriber = $container->getDefinition(AnonymizerLogPlugin::class); |
41
|
3 |
|
$subscriber->replaceArgument('$elements', $config['anonymize_logs']['elements']); |
42
|
|
|
$subscriber->replaceArgument('$attributes', $config['anonymize_logs']['attributes']); |
43
|
|
|
} |
44
|
|
|
$subscriber->replaceArgument(0, new Reference($config['logger'])); |
45
|
|
|
$subscriber->addTag('kernel.event_subscriber'); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|