Skip to content

Commit

Permalink
Fix EZP-28160: Added HTTP Cache purge after copying subtree (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwojs authored and andrerom committed Nov 2, 2017
1 parent e5f7381 commit 65cf537
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Resources/config/slot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 31 additions & 0 deletions src/SignalSlot/CopySubtreeSlot.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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.
*/
namespace EzSystems\PlatformHttpCacheBundle\SignalSlot;

use eZ\Publish\Core\SignalSlot\Signal;

/**
* A slot handling CopySubtreeSignal.
*/
class CopySubtreeSlot extends AbstractContentSlot
{
protected function generateTags(Signal $signal)
{
/** @var \eZ\Publish\Core\SignalSlot\Signal\LocationService\CopySubtreeSignal $signal */
return [
'location-' . $signal->targetParentLocationId,
'parent-' . $signal->targetParentLocationId,
];
}

protected function supports(Signal $signal)
{
return $signal instanceof Signal\LocationService\CopySubtreeSignal;
}
}
47 changes: 47 additions & 0 deletions tests/SignalSlot/CopySubtreeSlotTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?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.
*/
namespace EzSystems\PlatformHttpCacheBundle\Tests\SignalSlot;

use EzSystems\PlatformHttpCacheBundle\SignalSlot\CopySubtreeSlot;
use eZ\Publish\Core\SignalSlot\Signal\LocationService\CopySubtreeSignal;

class CopySubtreeSlotTest extends AbstractContentSlotTest
{
private $subtreeId = 67;
private $targetParentLocationId = 43;
private $targetNewSubtreeId = 45;

public function createSignal()
{
return new CopySubtreeSignal([
'subtreeId' => $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];
}

}

0 comments on commit 65cf537

Please sign in to comment.