protected function processBeforeAction($actionName)
 {
     $this->file = File::loadById($this->fileId, array('STORAGE'));
     if (!$this->file) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOWNLOAD_CONTROLLER_ERROR_COULD_NOT_FIND_FILE'), self::ERROR_COULD_NOT_FIND_FILE)));
         $this->sendJsonErrorResponse();
     }
     if ($this->file instanceof FileLink && !$this->file->getRealObject()) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOWNLOAD_CONTROLLER_ERROR_COULD_NOT_FIND_FILE'), self::ERROR_COULD_NOT_FIND_REAL_FILE)));
         $this->sendJsonErrorResponse();
     }
     $this->checkPermissions();
     return true;
 }
Example #2
0
 /**
  * Returns real object of object.
  *
  * For example if object is link (@see FolderLink, @see FileLink), then method returns original object.
  * @return FileLink
  * @throws ObjectException
  */
 public function getRealObject()
 {
     $realObject = parent::getRealObject();
     if ($realObject === null) {
         return null;
     }
     if (!$realObject instanceof File) {
         throw new ObjectException('Wrong value in realObjectId, which do not specifies subclass of File');
     }
     return $realObject;
 }