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 | 5 | use artweb\artbox\language\models\Language; |
| 6 | 6 | use Yii; |
| 7 | 7 | use yii\base\Model; |
| 8 | + use yii\caching\Cache; | |
| 8 | 9 | use yii\db\pgsql\QueryBuilder; |
| 9 | 10 | use yii\db\Query; |
| 10 | 11 | use yii\helpers\ArrayHelper; |
| ... | ... | @@ -249,6 +250,7 @@ |
| 249 | 250 | fclose($handle); |
| 250 | 251 | |
| 251 | 252 | if ($result[ 'end' ]) { |
| 253 | + $this->flushCache(); | |
| 252 | 254 | unlink(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFilePrices')); |
| 253 | 255 | } |
| 254 | 256 | |
| ... | ... | @@ -800,6 +802,7 @@ |
| 800 | 802 | fclose($handle); |
| 801 | 803 | |
| 802 | 804 | if ($result[ 'end' ]) { |
| 805 | + $this->flushCache(); | |
| 803 | 806 | // unlink(Yii::getAlias('@uploadDir') . '/' . Yii::getAlias('@uploadFileProducts')); |
| 804 | 807 | } |
| 805 | 808 | |
| ... | ... | @@ -920,5 +923,23 @@ |
| 920 | 923 | } |
| 921 | 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 | 946 | \ No newline at end of file | ... | ... |