/** */ protected function unSerialize() { foreach ($this->attributes as $attribute => $options) { $options = array_merge(['class' => File::className(), 'filePath' => $this->path, 'fileUrl' => $this->url, 'folder' => is_string($this->folder) ? $this->folder : function () use($attribute) { return call_user_func($this->folder, $this->owner, $attribute, $this); }], $options); $file = Yii::createObject($options); $file->initValue($this->owner->getAttribute($attribute)); $this->owner->setAttribute($attribute, $file); } }
/** * @inheritdoc */ public function save() { foreach ($this->types as $type => $options) { $this->getType($type); } if (parent::save() === true) { foreach ($this->data as $type => $file) { $file->setValue(null); $file->save(); } $this->data = []; $this->makeImages(); } }