Commit 01863172 authored by Tino Goratsch's avatar Tino Goratsch

fixed the cache invalidation logic when in production mode

parent 60d5eaec
......@@ -7,40 +7,28 @@
namespace ACP3\Modules\ACP3\System\Event\Listener;
use ACP3\Core\Modules;
use ACP3\Core\Settings\SettingsInterface;
use ACP3\Modules\ACP3\System\Installer\Schema;
use ACP3\Modules\ACP3\System\Model\Repository\SettingsRepository;
class OnModelAfterSaveListener
{
/**
* @var SettingsRepository
* @var SettingsInterface
*/
private $settingsRepository;
/**
* @var Modules
*/
private $modules;
private $settings;
/**
* OnModelAfterSaveListener constructor.
* @param Modules $modules
* @param SettingsRepository $settingsRepository
* @param SettingsInterface $settings
*/
public function __construct(
Modules $modules,
SettingsRepository $settingsRepository)
SettingsInterface $settings)
{
$this->settingsRepository = $settingsRepository;
$this->modules = $modules;
$this->settings = $settings;
}
public function invalidatePageCache()
{
$systemModuleId = $this->modules->getModuleId(Schema::MODULE_NAME);
$this->settingsRepository->update(
['value' => false],
['module_id' => $systemModuleId, 'name' => 'page_cache_is_valid']
);
$this->settings->saveSettings(['page_cache_is_valid' => false], Schema::MODULE_NAME);
}
}
<?php
/**
* Copyright (c) 2016 by the ACP3 Developers.
* See the LICENCE file at the top-level module directory for licencing details.
*/
namespace ACP3\Modules\ACP3\System\Event\Listener;
use ACP3\Core\Modules;
use ACP3\Modules\ACP3\System\Installer\Schema;
use ACP3\Modules\ACP3\System\Model\Repository\SettingsRepository;
class OnSettingsSaveBeforeListener
{
/**
* @var SettingsRepository
*/
private $settingsRepository;
/**
* @var Modules
*/
private $modules;
/**
* OnModelAfterSaveListener constructor.
* @param Modules $modules
* @param SettingsRepository $settingsRepository
*/
public function __construct(
Modules $modules,
SettingsRepository $settingsRepository)
{
$this->settingsRepository = $settingsRepository;
$this->modules = $modules;
}
public function invalidatePageCache()
{
$systemModuleId = $this->modules->getModuleId(Schema::MODULE_NAME);
$this->settingsRepository->update(
['value' => false],
['module_id' => $systemModuleId, 'name' => 'page_cache_is_valid']
);
}
}
......@@ -2,11 +2,17 @@ services:
system.event.listener.on_model_after_save_listener:
class: ACP3\Modules\ACP3\System\Event\Listener\OnModelAfterSaveListener
arguments:
- '@core.modules'
- '@system.model.settingsrepository'
- '@core.config'
tags:
- { name: core.eventListener, event: core.model.after_save, method: invalidatePageCache }
- { name: core.eventListener, event: core.model.after_delete, method: invalidatePageCache }
system.event.listener.on_settings_save_before_listener:
class: ACP3\Modules\ACP3\System\Event\Listener\OnSettingsSaveBeforeListener
arguments:
- '@core.modules'
- '@system.model.settingsrepository'
tags:
- { name: core.eventListener, event: core.settings.save_before, method: invalidatePageCache }
system.event.listener.on_layout_content_before_listener:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment