Skip to content

Commit

Permalink
[EZP-28156] Use ezplatform-http-cache services when available (ezsyst…
Browse files Browse the repository at this point in the history
…ems#120)

* [EZP-28156] Use ezplatform-http-cache services when available

* CS
  • Loading branch information
wizhippo authored and andrerom committed Oct 30, 2017
1 parent 9f6d607 commit 84065ab
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
36 changes: 36 additions & 0 deletions bundle/DependencyInjection/Compiler/HttpCachePass.php
@@ -0,0 +1,36 @@
<?php
/**
* This file is part of the eZ Publish Kernel package.
*
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
* @version //autogentag//
*/
namespace eZ\Bundle\EzPublishLegacyBundle\DependencyInjection\Compiler;

use eZ\Bundle\EzPublishCoreBundle\Cache\Http\InstantCachePurger;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;

/**
* Pass modifying the switchable_http_cache_purger when ezplatform.http_cache is available.
*/
class HttpCachePass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (!$container->hasAlias('ezplatform.http_cache.purge_client')) {
return;
}

$container->addDefinitions([
'ezplatform.http_cache.purger' => new Definition(InstantCachePurger::class,
[new Reference('ezplatform.http_cache.purge_client')]),
]);

$container->getDefinition('ezpublish_legacy.switchable_http_cache_purger')
->replaceArgument(0, new Reference('ezplatform.http_cache.purger'));
}
}
2 changes: 2 additions & 0 deletions bundle/EzPublishLegacyBundle.php
Expand Up @@ -8,6 +8,7 @@
*/
namespace eZ\Bundle\EzPublishLegacyBundle;

use eZ\Bundle\EzPublishLegacyBundle\DependencyInjection\Compiler\HttpCachePass;
use eZ\Bundle\EzPublishLegacyBundle\DependencyInjection\Compiler\RememberMeListenerPass;
use eZ\Bundle\EzPublishLegacyBundle\DependencyInjection\Compiler\LegacyBundlesPass;
use eZ\Bundle\EzPublishLegacyBundle\DependencyInjection\Compiler\LegacySessionPass;
Expand Down Expand Up @@ -55,6 +56,7 @@ public function build(ContainerBuilder $container)
$container->addCompilerPass(new RoutingPass());
$container->addCompilerPass(new LegacySessionPass());
$container->addCompilerPass(new RememberMeListenerPass());
$container->addCompilerPass(new HttpCachePass());

/** @var \Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension $securityExtension */
$securityExtension = $container->getExtension('security');
Expand Down

0 comments on commit 84065ab

Please sign in to comment.