]> _ Git - cubist_cms-back.git/commitdiff
wait #5282 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 17 May 2022 08:12:16 +0000 (10:12 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 17 May 2022 08:12:16 +0000 (10:12 +0200)
src/app/Magic/Models/CubistMagicAbstractModel.php

index 97ea3756f68ef579150ec260f0d2732b47463249..f6adedae4dfe3edca1a2f47e450c744944f1b565 100644 (file)
@@ -64,6 +64,8 @@ class CubistMagicAbstractModel extends Model implements HasMedia
     protected $_enableRevisionsButton = false;
     protected $_enableBulk = true;
 
+    protected $_flushCacheOnSave = true;
+
     public $timestamps = true;
 
     protected $_enableTrackNonDefaultValues = false;
@@ -878,7 +880,9 @@ class CubistMagicAbstractModel extends Model implements HasMedia
     protected function finishSave(array $options)
     {
         parent::finishSave($options);
-        $this->flushCache();
+        if ($this->_flushCacheOnSave) {
+            $this->flushCache();
+        }
     }
 
     public function flushCache($tags = [])
@@ -1170,6 +1174,13 @@ class CubistMagicAbstractModel extends Model implements HasMedia
         return $saved;
     }
 
+    public function saveWithoutFlushingCache($options = [])
+    {
+        $this->_flushCacheOnSave = false;
+        $this->save($options);
+        $this->_flushCacheOnSave = true;
+    }
+
     public static function refreshComposedAttributes()
     {
         $all = static::all();