From 5ad602b091d81cdf3089cd1759d2599e968d9752 Mon Sep 17 00:00:00 2001 From: yarik Date: Sat, 10 Dec 2016 21:29:44 +0200 Subject: [PATCH] Cache flush after import --- models/Import.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+), 0 deletions(-) diff --git a/models/Import.php b/models/Import.php index 7a35fef..c9df4e2 100755 --- a/models/Import.php +++ b/models/Import.php @@ -5,6 +5,7 @@ use artweb\artbox\language\models\Language; use Yii; use yii\base\Model; + use yii\caching\Cache; use yii\db\pgsql\QueryBuilder; use yii\db\Query; use yii\helpers\ArrayHelper; @@ -249,6 +250,7 @@ fclose($handle); if ($result[ 'end' ]) { + $this->flushCache(); unlink(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFilePrices')); } @@ -800,6 +802,7 @@ fclose($handle); if ($result[ 'end' ]) { + $this->flushCache(); // unlink(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFileProducts')); } @@ -920,5 +923,23 @@ } return $options; } + + /** + * Flush cache + * + * @param string $component + * + * @return bool + */ + protected function flushCache(string $component = 'cache') + { + /** + * @var Cache $cache + */ + $cache = \Yii::$app->get($component, false); + if(!empty($cache)) { + return $cache->flush(); + } + } } \ No newline at end of file -- libgit2 0.21.4