Commits

Bogdan Savluk committed d19da4f

Added option to force image versions update in changeConfig method even if no changes in config was made. Added auto-fix for wrong gallery_id in model.

Comments (0)

Files changed (1)

GalleryBehavior.php

     {
         parent::beforeSave($event);
         if ($event->isValid) {
-            if (empty($this->getOwner()->{$this->idAttribute})) {
+            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()
+    public function changeConfig($force=false)
     {
         /** @var $gallery Gallery */
         $gallery = $this->getGallery();
         if ($gallery->versions_data != serialize($this->versions)) {
             $changed = true;
         }
-        if ($changed) {
+        if ($force||$changed) {
             foreach ($gallery->galleryPhotos as $photo) {
                 $photo->removeImages();
             }