-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #17 - Implements IndentityInterface - Clean cache after save reta…
…iler
- Loading branch information
Maxime LECLERCQ
committed
Sep 6, 2018
1 parent
23a6650
commit b89ba3d
Showing
4 changed files
with
133 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
/** | ||
* DISCLAIMER | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\StoreLocator | ||
* @author Maxime Leclercq <maxime.leclercq@smile.fr> | ||
* @copyright 2018 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
namespace Smile\StoreLocator\Observer; | ||
|
||
use Magento\PageCache\Model\Cache\Type as Cache; | ||
use Magento\Framework\Event\Observer; | ||
use Magento\Framework\Event\ObserverInterface; | ||
use Smile\Seller\Api\Data\SellerInterface; | ||
use Smile\StoreLocator\Block\Search; | ||
|
||
/** | ||
* Clean store locator cache observer. | ||
* | ||
* @category Smile | ||
* @package Smile\StoreLocator | ||
*/ | ||
class CleanStoreLocatorCache implements ObserverInterface | ||
{ | ||
/** | ||
* @var Cache | ||
*/ | ||
private $cache; | ||
|
||
/** | ||
* CleanStoreLocatorCache constructor. | ||
* | ||
* @param Cache $cache Cache. | ||
*/ | ||
public function __construct(Cache $cache) | ||
{ | ||
$this->cache = $cache; | ||
} | ||
|
||
/** | ||
* Clean store locator marker cache when save a seller. | ||
* | ||
* @param Observer $observer | ||
* | ||
* @return void | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameters) | ||
*/ | ||
public function execute(Observer $observer) | ||
{ | ||
/** @var SellerInterface $seller */ | ||
$seller = $observer->getEvent()->getSeller(); | ||
if ($seller->hasDataChanges()) { | ||
$this->cache->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, [Search::CACHE_TAG]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this module to newer | ||
* versions in the future. | ||
* | ||
* @category Smile | ||
* @package Smile\StoreLocator | ||
* @author Maxime Leclercq <maxime.leclercq@smile.fr> | ||
* @copyright 2018 Smile | ||
* @license Open Software License ("OSL") v. 3.0 | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> | ||
<event name="smile_seller_save_after"> | ||
<observer name="smile_store_locator_clear_cache" instance="Smile\StoreLocator\Observer\CleanStoreLocatorCache" shared="false" /> | ||
</event> | ||
<event name="smile_seller_delete_after"> | ||
<observer name="smile_store_locator_clear_cache" instance="Smile\StoreLocator\Observer\CleanStoreLocatorCache" shared="false" /> | ||
</event> | ||
</config> |