private function refresh($identifier, $fields) { $model = StorageEffect::find()->where(['identifier' => $identifier])->one(); if ($model) { $model->setAttributes($fields, false); $model->update(false); } else { $this->getImporter()->addLog('filters', 'effect "' . $identifier . '" added'); $insert = new StorageEffect(); $insert->identifier = $identifier; $insert->setAttributes($fields, false); $insert->insert(false); } }
private function resolveEffect($effectIdentifier) { $model = \admin\models\StorageEffect::find()->where(['identifier' => $effectIdentifier])->asArray()->one(); if ($model) { return $model; } throw new \Exception("the provieded effect '{$effectIdentifier}' identifier does not exists in database."); }
public function getEffect() { return $this->hasOne(\admin\models\StorageEffect::className(), ['id' => 'effect_id']); }
/** * 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; }