Commit 5ad602b091d81cdf3089cd1759d2599e968d9752
1 parent
8b83e9d1
Cache flush after import
Showing
1 changed file
with
21 additions
and
0 deletions
Show diff stats
models/Import.php
| @@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
| 5 | use artweb\artbox\language\models\Language; | 5 | use artweb\artbox\language\models\Language; |
| 6 | use Yii; | 6 | use Yii; |
| 7 | use yii\base\Model; | 7 | use yii\base\Model; |
| 8 | + use yii\caching\Cache; | ||
| 8 | use yii\db\pgsql\QueryBuilder; | 9 | use yii\db\pgsql\QueryBuilder; |
| 9 | use yii\db\Query; | 10 | use yii\db\Query; |
| 10 | use yii\helpers\ArrayHelper; | 11 | use yii\helpers\ArrayHelper; |
| @@ -249,6 +250,7 @@ | @@ -249,6 +250,7 @@ | ||
| 249 | fclose($handle); | 250 | fclose($handle); |
| 250 | 251 | ||
| 251 | if ($result[ 'end' ]) { | 252 | if ($result[ 'end' ]) { |
| 253 | + $this->flushCache(); | ||
| 252 | unlink(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFilePrices')); | 254 | unlink(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFilePrices')); |
| 253 | } | 255 | } |
| 254 | 256 | ||
| @@ -800,6 +802,7 @@ | @@ -800,6 +802,7 @@ | ||
| 800 | fclose($handle); | 802 | fclose($handle); |
| 801 | 803 | ||
| 802 | if ($result[ 'end' ]) { | 804 | if ($result[ 'end' ]) { |
| 805 | + $this->flushCache(); | ||
| 803 | // unlink(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFileProducts')); | 806 | // unlink(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFileProducts')); |
| 804 | } | 807 | } |
| 805 | 808 | ||
| @@ -920,5 +923,23 @@ | @@ -920,5 +923,23 @@ | ||
| 920 | } | 923 | } |
| 921 | return $options; | 924 | return $options; |
| 922 | } | 925 | } |
| 926 | + | ||
| 927 | + /** | ||
| 928 | + * Flush cache | ||
| 929 | + * | ||
| 930 | + * @param string $component | ||
| 931 | + * | ||
| 932 | + * @return bool | ||
| 933 | + */ | ||
| 934 | + protected function flushCache(string $component = 'cache') | ||
| 935 | + { | ||
| 936 | + /** | ||
| 937 | + * @var Cache $cache | ||
| 938 | + */ | ||
| 939 | + $cache = \Yii::$app->get($component, false); | ||
| 940 | + if(!empty($cache)) { | ||
| 941 | + return $cache->flush(); | ||
| 942 | + } | ||
| 943 | + } | ||
| 923 | } | 944 | } |
| 924 | 945 | ||
| 925 | \ No newline at end of file | 946 | \ No newline at end of file |