/** * @param $oldModel FileUploadBehavior */ public function afterSave($oldModel) { parent::afterSave($oldModel); if ($this->_file instanceof UploadedFile) { foreach ($this->options['thumbs'] as $id => $options) { if (isset($options['imagine']) || $options['saveOptions']) { if (empty($options['saveOptions'])) { $options['saveOptions'] = []; } if (empty($options['imagine'])) { $options['imagine'] = function ($filename) { return Image::getImagine()->open($filename); }; } $this->processImage($options['imagine'], $options['saveOptions'], $id); } } if (isset($this->options['imagine']) || $this->options['saveOptions']) { if (empty($this->options['saveOptions'])) { $this->options['saveOptions'] = []; } if (empty($this->options['imagine'])) { $this->options['imagine'] = function ($filename) { return Image::getImagine()->open($filename); }; } $this->processImage($this->options['imagine'], $this->options['saveOptions']); } } }
public function init() { $attributes = $this->attributes; foreach ($attributes as $attribute => $options) { if (isset($options['handler'])) { $handler = $options['handler']; unset($options['handler']); } else { $handler = FileHandler::className(); } $this->attributes[$attribute] = new $handler(['attribute' => $attribute, 'behavior' => $this, 'options' => $options]); } }