/**
  * валидация переданных названий тумб у категории
  */
 public function validateThumbsName()
 {
     if (!is_array($this->thumbsName) || empty($this->thumbsName)) {
         $this->addError('thumbsName', 'THUMBS_IS_EMPTY');
         return false;
     }
     foreach ($this->thumbsName as $thumbName) {
         $thumbRow = Thumbs::findOne(['thumb_category_id' => $this->_categoryRow->getId(), 'name' => $thumbName]);
         if (is_null($thumbRow)) {
             $this->addError('thumbsName', $thumbName . ' IS_NOT_EXITSTS');
         }
     }
 }
 /**
  * @param integer $categoryId
  * @param array $thumbsName
  * @return Thumbs[]
  */
 public function get($categoryId, $fileInformationId, $thumbsName = NULL)
 {
     $listThumbs = Thumbs::find()->where(['thumb_category_id' => $categoryId]);
     if (!is_null($thumbsName)) {
         SystemExceptionIsArray::getInstance()->validate($thumbsName);
         $listThumbs->andWhere(['name' => $thumbsName]);
     }
     $result = [];
     foreach ($listThumbs->all() as $thumb) {
         /**
          * @var ThumbsFile $thumbFileRow
          */
         $thumbFileRow = $thumb->getThumbsFile()->where(['file_information_id' => $fileInformationId])->one();
         $thumbFileRow->setFilePath(\Yii::$app->params['cdn'] . DIRECTORY_SEPARATOR . $thumbFileRow->getFilePath());
         $result[$thumb['name']]['file'] = $thumbFileRow;
     }
     return $result;
 }
 /**
  * @param Thumbs $thumbs
  * @return self
  */
 private function _createThumbsImage(Thumbs $thumbs, SystemImage &$image)
 {
     $image->scaleImage($thumbs->getWidth(), $thumbs->getHeigth());
     $imagePath = $this->_basePath . $this->_thumbFileSaveDir . $this->_getThumbFilePath($thumbs);
     $image->writeImageToFile($imagePath);
     return $this;
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getImageThumbs()
 {
     return $this->hasMany(Thumbs::className(), ['thumb_category_id' => 'id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getThumbs()
 {
     return $this->hasOne(Thumbs::className(), ['id' => 'thumbs_id']);
 }