mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
ref
This commit is contained in:
@@ -31,8 +31,8 @@ namespace Espo\Core\ApplicationRunners;
|
||||
|
||||
use Espo\Core\{
|
||||
Application\Runner,
|
||||
DataManager,
|
||||
Exceptions\Error,
|
||||
Utils\CacheClearer,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -42,11 +42,11 @@ class ClearCache implements Runner
|
||||
{
|
||||
use Cli;
|
||||
|
||||
private CacheClearer $cacheClearer;
|
||||
private DataManager $dataManager;
|
||||
|
||||
public function __construct(CacheClearer $cacheClearer)
|
||||
public function __construct(DataManager $dataManager)
|
||||
{
|
||||
$this->cacheClearer = $cacheClearer;
|
||||
$this->dataManager = $dataManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,6 +54,6 @@ class ClearCache implements Runner
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->cacheClearer->clear();
|
||||
$this->dataManager->clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,16 +34,16 @@ use Espo\Core\{
|
||||
Console\Command\Params,
|
||||
Console\IO,
|
||||
Exceptions\Error,
|
||||
Utils\CacheClearer,
|
||||
DataManager,
|
||||
};
|
||||
|
||||
class ClearCache implements Command
|
||||
{
|
||||
private CacheClearer $cacheClearer;
|
||||
private DataManager $dataManager;
|
||||
|
||||
public function __construct(CacheClearer $cacheClearer)
|
||||
public function __construct(DataManager $dataManager)
|
||||
{
|
||||
$this->cacheClearer = $cacheClearer;
|
||||
$this->dataManager = $dataManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +51,7 @@ class ClearCache implements Command
|
||||
*/
|
||||
public function run(Params $params, IO $io): void
|
||||
{
|
||||
$this->cacheClearer->clear();
|
||||
$this->dataManager->clearCache();
|
||||
|
||||
$io->writeLine("Cache has been cleared.");
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ use Espo\Core\Utils\Config\MissingDefaultParamsSaver as ConfigMissingDefaultPara
|
||||
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\ORM\EntityManagerProxy;
|
||||
use Espo\Core\Utils\CacheClearer;
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Core\Utils\Util;
|
||||
use Espo\Core\Utils\Config;
|
||||
@@ -62,7 +62,9 @@ class DataManager
|
||||
private Module $module;
|
||||
private RebuildActionProcessor $rebuildActionProcessor;
|
||||
private ConfigMissingDefaultParamsSaver $configMissingDefaultParamsSaver;
|
||||
private CacheClearer $cacheClearer;
|
||||
private FileManager $fileManager;
|
||||
|
||||
private string $cachePath = 'data/cache';
|
||||
|
||||
public function __construct(
|
||||
EntityManagerProxy $entityManager,
|
||||
@@ -76,7 +78,7 @@ class DataManager
|
||||
Module $module,
|
||||
RebuildActionProcessor $rebuildActionProcessor,
|
||||
ConfigMissingDefaultParamsSaver $configMissingDefaultParamsSaver,
|
||||
CacheClearer $cacheClearer
|
||||
FileManager $fileManager
|
||||
) {
|
||||
$this->entityManager = $entityManager;
|
||||
$this->config = $config;
|
||||
@@ -89,7 +91,7 @@ class DataManager
|
||||
$this->module = $module;
|
||||
$this->rebuildActionProcessor = $rebuildActionProcessor;
|
||||
$this->configMissingDefaultParamsSaver = $configMissingDefaultParamsSaver;
|
||||
$this->cacheClearer = $cacheClearer;
|
||||
$this->fileManager = $fileManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,7 +120,15 @@ class DataManager
|
||||
*/
|
||||
public function clearCache(): void
|
||||
{
|
||||
$this->cacheClearer->clear();
|
||||
$this->module->clearCache();
|
||||
|
||||
$result = $this->fileManager->removeInDir($this->cachePath);
|
||||
|
||||
if (!$result) {
|
||||
throw new Error("Error while clearing cache");
|
||||
}
|
||||
|
||||
$this->updateCacheTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2022 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Utils;
|
||||
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Utils\Config\ConfigWriter;
|
||||
use Espo\Core\Utils\File\Manager as FileManager;
|
||||
|
||||
class CacheClearer
|
||||
{
|
||||
private ConfigWriter $configWriter;
|
||||
private FileManager $fileManager;
|
||||
private Module $module;
|
||||
|
||||
private string $cachePath = 'data/cache';
|
||||
|
||||
public function __construct(
|
||||
ConfigWriter $configWriter,
|
||||
FileManager $fileManager,
|
||||
Module $module
|
||||
){
|
||||
$this->configWriter = $configWriter;
|
||||
$this->fileManager = $fileManager;
|
||||
$this->module = $module;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Error
|
||||
*/
|
||||
public function clear(): void
|
||||
{
|
||||
$this->module->clearCache();
|
||||
|
||||
$result = $this->fileManager->removeInDir($this->cachePath);
|
||||
|
||||
if (!$result) {
|
||||
throw new Error("Error while clearing cache");
|
||||
}
|
||||
|
||||
$this->updateCacheTimestamp();
|
||||
}
|
||||
|
||||
private function updateCacheTimestamp(): void
|
||||
{
|
||||
$this->configWriter->updateCacheTimestamp();
|
||||
$this->configWriter->save();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user