vendor/pimcore/pimcore/lib/Analytics/Piwik/EventListener/CacheListener.php line 47

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * Pimcore
  5.  *
  6.  * This source file is available under two different licenses:
  7.  * - GNU General Public License version 3 (GPLv3)
  8.  * - Pimcore Enterprise License (PEL)
  9.  * Full copyright and license information is available in
  10.  * LICENSE.md which is distributed with this source code.
  11.  *
  12.  * @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  13.  * @license    http://www.pimcore.org/license     GPLv3 and PEL
  14.  */
  15. namespace Pimcore\Analytics\Piwik\EventListener;
  16. use Pimcore\Cache\Core\CoreHandlerInterface;
  17. use Pimcore\Event\Admin\Report\SettingsEvent;
  18. use Pimcore\Event\Admin\ReportEvents;
  19. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  20. class CacheListener implements EventSubscriberInterface
  21. {
  22.     /**
  23.      * @var CoreHandlerInterface
  24.      */
  25.     private $cache;
  26.     /**
  27.      * @param CoreHandlerInterface $cache
  28.      */
  29.     public function __construct(CoreHandlerInterface $cache)
  30.     {
  31.         $this->cache $cache;
  32.     }
  33.     public static function getSubscribedEvents()
  34.     {
  35.         return [
  36.             ReportEvents::SAVE_SETTINGS => 'onSaveSettings'
  37.         ];
  38.     }
  39.     public function onSaveSettings(SettingsEvent $event)
  40.     {
  41.         // clear piwik cache tag when report settings are saved
  42.         // to make sure cached data (e.g. widgets) is refreshed
  43.         $this->cache->clearTag('piwik');
  44.     }
  45. }