From 65cf537126864e32ed389cae9b478a7694a9fdef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20W=C3=B3js?= Date: Thu, 2 Nov 2017 09:50:53 +0100 Subject: [PATCH] Fix EZP-28160: Added HTTP Cache purge after copying subtree (#18) --- src/Resources/config/slot.yml | 6 +++ src/SignalSlot/CopySubtreeSlot.php | 31 ++++++++++++++++ tests/SignalSlot/CopySubtreeSlotTest.php | 47 ++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 src/SignalSlot/CopySubtreeSlot.php create mode 100644 tests/SignalSlot/CopySubtreeSlotTest.php diff --git a/src/Resources/config/slot.yml b/src/Resources/config/slot.yml index 9183fbed..aa17f911 100644 --- a/src/Resources/config/slot.yml +++ b/src/Resources/config/slot.yml @@ -16,6 +16,12 @@ services: tags: - { name: ezpublish.api.slot, signal: ContentService\CopyContentSignal } + ezplatform.http_cache.signalslot.copy_subtree: + class: EzSystems\PlatformHttpCacheBundle\SignalSlot\CopySubtreeSlot + parent: ezplatform.http_cache.signalslot.abstract_content + tags: + - { name: ezpublish.api.slot, signal: ContentService\CopySubtreeSignal } + ezplatform.http_cache.signalslot.create_location: class: EzSystems\PlatformHttpCacheBundle\SignalSlot\CreateLocationSlot parent: ezplatform.http_cache.signalslot.abstract_content diff --git a/src/SignalSlot/CopySubtreeSlot.php b/src/SignalSlot/CopySubtreeSlot.php new file mode 100644 index 00000000..0c5b5705 --- /dev/null +++ b/src/SignalSlot/CopySubtreeSlot.php @@ -0,0 +1,31 @@ +targetParentLocationId, + 'parent-' . $signal->targetParentLocationId, + ]; + } + + protected function supports(Signal $signal) + { + return $signal instanceof Signal\LocationService\CopySubtreeSignal; + } +} diff --git a/tests/SignalSlot/CopySubtreeSlotTest.php b/tests/SignalSlot/CopySubtreeSlotTest.php new file mode 100644 index 00000000..8fd58ca5 --- /dev/null +++ b/tests/SignalSlot/CopySubtreeSlotTest.php @@ -0,0 +1,47 @@ + $this->subtreeId, + 'targetParentLocationId' => $this->targetParentLocationId, + 'targetNewSubtreeId' => $this->targetNewSubtreeId + ]); + } + + public function generateTags() + { + return [ + 'location-' . $this->targetParentLocationId, + 'parent-' . $this->targetParentLocationId + ]; + } + + public function getSlotClass() + { + return CopySubtreeSlot::class; + } + + public function getReceivedSignalClasses() + { + return [CopySubtreeSignal::class]; + } + +}