From 7fc5530e5a65ca086b7d8e4b00a533b6d4f9a84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morel=20Se=CC=81bastien?= Date: Wed, 1 Jun 2016 19:02:18 -0700 Subject: [PATCH] Dispatch the events from the Legacy --- bundle/Cache/SwitchableHttpCachePurger.php | 16 ++++++++++++++-- bundle/Resources/config/services.yml | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/bundle/Cache/SwitchableHttpCachePurger.php b/bundle/Cache/SwitchableHttpCachePurger.php index 79844750..457a3d06 100644 --- a/bundle/Cache/SwitchableHttpCachePurger.php +++ b/bundle/Cache/SwitchableHttpCachePurger.php @@ -8,6 +8,7 @@ namespace eZ\Bundle\EzPublishLegacyBundle\Cache; use eZ\Publish\Core\MVC\Symfony\Cache\GatewayCachePurger; +use eZ\Publish\API\Repository\LocationService; /** * A GatewayCachePurger decorator that allows the actual purger to be switched on/off. @@ -19,9 +20,13 @@ class SwitchableHttpCachePurger implements GatewayCachePurger /** @var \eZ\Publish\Core\MVC\Symfony\Cache\GatewayCachePurger */ private $gatewayCachePurger; - public function __construct(GatewayCachePurger $gatewayCachePurger) + /** @var \eZ\Publish\API\Repository\LocationService */ + private $locationService; + + public function __construct(GatewayCachePurger $gatewayCachePurger, LocationService $locationService) { $this->gatewayCachePurger = $gatewayCachePurger; + $this->locationService = $locationService; } public function purge($cacheElements) @@ -30,7 +35,14 @@ public function purge($cacheElements) return $cacheElements; } - return $this->gatewayCachePurger->purge($cacheElements); + foreach ($cacheElements as $locationId) { + $location = $this->locationService->loadLocation($locationId); + if ($locationId != 1) { + $this->purgeForContent($location->contentId); + } + } + + return $cacheElements; } public function purgeAll() diff --git a/bundle/Resources/config/services.yml b/bundle/Resources/config/services.yml index 02ed36a0..d37cd9ae 100644 --- a/bundle/Resources/config/services.yml +++ b/bundle/Resources/config/services.yml @@ -263,7 +263,7 @@ services: ezpublish_legacy.switchable_http_cache_purger: class: %ezpublish_legacy.switchable_http_cache_purger.class% - arguments: ["@ezpublish.http_cache.purger"] + arguments: ["@ezpublish.http_cache.purger", "@ezpublish.api.service.location"] ezpublish_legacy.content_exception_handler: class: %ezpublish_legacy.content_exception_handler.class%