public function getFileContent() { $file = $this->getAttribute('file'); if (empty($file) && !$this->getIsNewRecord()) { $file = $this->refreshFile(); } if (empty($file)) { return null; } elseif ($file instanceof Download) { $fileSize = $file->getSize(); if (empty($fileSize)) { return null; } else { return $file->toString(); } } elseif ($file instanceof UploadedFile) { return file_get_contents($file->tempName); } elseif (is_string($file)) { if (file_exists($file)) { return file_get_contents($file); } else { throw new InvalidParamException("File '{$file}' does not exist."); } } else { throw new InvalidParamException('Unsupported type of "file" attribute.'); } }