/** * Backup Gists * * If the time of last backup is less than 5 minutes ago, interrupts and returns a string. * Otherwise returns the archived file response. * * @return string | \Symfony\Component\HttpFoundation\BinaryFileResponse */ public function backup() { $user = $this->userFinder->getAuthenticatedUser(); $userCanBackup = GistBackupHandler::checkLastBackupTime($user); if (!$userCanBackup) { return 'WAIT_A_MINUTE'; } else { $gists = $this->gistFinder->getAll(); $gistBackupHandler = $this->gistBackupHandlerFactory->getInstance($user, $gists); $zipPath = $gistBackupHandler->backup(); return Response::download($zipPath, null, ['Set-Cookie' => 'fileDownload=true; path=/']); } }