private function refresh($identifier, $fields)
 {
     $model = StorageEffect::find()->where(['identifier' => $identifier])->one();
     if ($model) {
         $model->setAttributes($fields, false);
         $model->update(false);
     } else {
         $this->addLog('effect "' . $identifier . '" added');
         $insert = new StorageEffect();
         $insert->identifier = $identifier;
         $insert->setAttributes($fields, false);
         $insert->insert(false);
     }
 }
 public function getEffect()
 {
     return $this->hasOne(StorageEffect::className(), ['id' => 'effect_id']);
 }
Esempio n. 3
0
 /**
  * Find the effect model based on the effect identifier. If the effect could not found an exception will
  * be thrown.
  *
  * @param string $effectIdentifier The name of effect, used EFFECT prefixed constants like
  * + EFFECT_RESIZE
  * + EFFECT_THUMBNAIL
  * + EFFECT_CROP
  * @return array Contain an array with the effect properties.
  * @throws Exception
  */
 public function findEffect($effectIdentifier)
 {
     // find effect model based on the effectIdentifier
     $model = StorageEffect::find()->where(['identifier' => $effectIdentifier])->asArray()->one();
     // if the effect model could not found, throw Exception.
     if (!$model) {
         throw new Exception("The requested effect '{$effectIdentifier}' does not exist.");
     }
     // array
     return $model;
 }