-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSwagEssentials.php
More file actions
51 lines (40 loc) · 1.51 KB
/
SwagEssentials.php
File metadata and controls
51 lines (40 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php declare(strict_types=1);
namespace SwagEssentials;
use Shopware\Components\Plugin;
use SwagEssentials\Redis\CacheManagerCompilerPass;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
class SwagEssentials extends Plugin
{
public function build(ContainerBuilder $container)
{
parent::build($container);
if (!$container->hasParameter('shopware.swag_essentials.modules')) {
return;
}
/** @var array $swagEssentialsModules */
$swagEssentialsModules = $container->getParameter('shopware.swag_essentials.modules');
$loader = new XmlFileLoader($container, new FileLocator());
$redisLoaded = false;
foreach ($swagEssentialsModules as $module => $active) {
if (!$active) {
continue;
}
if (strpos($module, 'Redis') === 0) {
$module = str_replace('Redis', 'Redis/', $module);
if (!$redisLoaded) {
$loader->load($this->getPath() . '/Redis/services.xml');
$redisLoaded = true;
}
}
$serviceFile = $this->getPath() . '/' . $module . '/services.xml';
if (file_exists($serviceFile)) {
$loader->load($serviceFile);
}
}
if ($redisLoaded) {
$container->addCompilerPass(new CacheManagerCompilerPass());
}
}
}