/** * @param array $data * @return BaseData */ protected function unpackEntity(array $data) { $ret = new FileData(); $ret->setAllowedParentTypes(FileParentType::getAll()); foreach ($data as $key => $val) { switch ($key) { case 'title': case 'description': $ret->{$key} = $val; break; case 'order': case 'parentId': case 'parentType': $ret->{$key} = (int) $val; break; } } return $ret; }
/** * @param array $data * @return BaseData */ protected function unpackEntity(array $data) { $ret = new FileData(); $ret->setAllowedParentTypes(FileParentType::getAll()); foreach ($data as $key => $val) { switch ($key) { case 'title': case 'description': $ret->{$key} = $val; break; case 'order': case 'parentId': case 'parentType': $ret->{$key} = (int) $val; break; } } $ret->size = (int) ($this->file['size'] / 1024); $ret->origFileName = basename($this->file['name']); $ret->fileName = $ret->origFileName; $ret->createDate = time(); $ret->userId = $this->user->data()->id; $ret->type = FileData::TYPE_IMAGE; return $ret; }