-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathWebpFormatVariationPathGeneratorDecoratorPass.php
More file actions
42 lines (33 loc) · 1.49 KB
/
WebpFormatVariationPathGeneratorDecoratorPass.php
File metadata and controls
42 lines (33 loc) · 1.49 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
<?php
declare(strict_types=1);
namespace Netgen\Bundle\SiteBundle\DependencyInjection\Compiler;
use Ibexa\Bundle\Core\Imagine\VariationPathGenerator\WebpFormatVariationPathGenerator as BaseWebpFormatVariationPathGenerator;
use Netgen\Bundle\SiteBundle\Core\Imagine\VariationPathGenerator\WebpFormatVariationPathGenerator;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use function array_keys;
use function in_array;
use function is_array;
class WebpFormatVariationPathGeneratorDecoratorPass implements CompilerPassInterface
{
/**
* Overrides default Webp image alias variation path generator decorator to comply with legacy variation URL pattern
* We do this only if we have Netgen AdminUI installed (legacy-based administration).
*/
public function process(ContainerBuilder $container): void
{
if (!$container->hasParameter('kernel.bundles') || !is_array($container->getParameter('kernel.bundles'))) {
return;
}
$activatedBundles = array_keys($container->getParameter('kernel.bundles'));
if (!in_array('NetgenAdminUIBundle', $activatedBundles, true)) {
return;
}
if (!$container->has(BaseWebpFormatVariationPathGenerator::class)) {
return;
}
$container
->findDefinition(BaseWebpFormatVariationPathGenerator::class)
->setClass(WebpFormatVariationPathGenerator::class);
}
}