/** * Removes file * * @param string $hash File hash * @param int $userId User ID * @throws ModelException */ public function removeFile($hash, $userId) { $path = UPLOADED_FILES . $hash; $file = $this->dao->get($hash); if ($file->userId != $userId) { throw new ModelException('File unavailable'); } if (file_exists($path)) { if (!unlink($path)) { throw new ModelException('Can\'t remove file'); } } $this->dao->delete($file); }
/** * Gets user by ID * * @param int $id User ID * @return null|\entities\User */ public function get($id) { return $this->dao->get($id); }