Commits

Bogdan Savluk committed 34511da

update changeConfig method

Comments (0)

Files changed (1)

GalleryBehavior.php

      */
     public $versions;
     /** @var boolean does images in gallery need names */
-    public $name=true;
+    public $name = true;
     /** @var boolean does images in gallery need descriptions */
-    public $description=true;
+    public $description = true;
     /** @var boolean does images in gallery need links */
-    public $link=false;
+    public $link = false;
 
     private $_gallery;
 
     {
         parent::beforeSave($event);
         if ($event->isValid) {
-            if (empty($this->getOwner()->{$this->idAttribute}) || $this->getGallery()===null) {
+            if (empty($this->getOwner()->{$this->idAttribute}) || $this->getGallery() === null) {
                 $gallery = new Gallery();
                 $gallery->name = $this->name;
                 $gallery->description = $this->description;
     }
 
     /** Method for changing gallery configuration and regeneration of images versions */
-    public function changeConfig($force=false)
+    public function changeConfig($force = false, $skip = false)
     {
         /** @var $gallery Gallery */
         $gallery = $this->getGallery();
         if ($gallery->versions_data != serialize($this->versions)) {
             $changed = true;
         }
-        if ($force||$changed) {
-            foreach ($gallery->galleryPhotos as $photo) {
-                $photo->removeImages();
+        if ($force || $changed) {
+            if (!$skip) {
+                foreach ($gallery->galleryPhotos as $photo) {
+                    $photo->removeImages();
+                }
             }
-
             $gallery->name = $this->name;
             $gallery->description = $this->description;
             $gallery->link = $this->link;
             $gallery->versions = $this->versions;
             $gallery->save();
 
-            foreach ($gallery->galleryPhotos as $photo) {
-                $photo->updateImages();
+            if (!$skip) {
+                foreach ($gallery->galleryPhotos as $photo) {
+                    $photo->updateImages();
+                }
             }
         }
         $this->getOwner()->{$this->idAttribute} = $gallery->id;