/**
  * Method to update images name/description via AJAX.
  * On success returns JSON array of objects with new image info.
  *
  * @param $imagesData
  *
  * @throws HttpException
  * @return string
  */
 public function actionChangeData($imagesData)
 {
     if (count($imagesData) == 0) {
         throw new HttpException(400, 'Nothing to save');
     }
     $images = $this->behavior->updateImagesData($imagesData);
     $resp = array();
     foreach ($images as $model) {
         $resp[] = array('id' => $model->id, 'rank' => $model->rank, 'name' => (string) $model->name, 'description' => (string) $model->description, 'preview' => $model->getUrl('preview'));
     }
     return Json::encode($resp);
 }
Esempio n. 2
0
 public function behaviors()
 {
     return ['galleryBehavior' => ['class' => GalleryBehavior::className(), 'type' => 'products', 'extension' => 'png', 'directory' => Yii::getAlias('@imagesroot') . '/products/gallery', 'url' => Yii::getAlias('@images') . '/products/gallery']];
 }