Cleaning up unnecessary use of 'die' and 'exit'

This commit is contained in:
Dan Cryer 2015-02-12 12:37:56 +00:00
commit 2d5659d613
13 changed files with 188 additions and 106 deletions

View file

@ -81,8 +81,9 @@ class ProjectController extends \PHPCI\Controller
$pages = $builds[1] == 0 ? 1 : ceil($builds[1] / $per_page);
if ($page > $pages) {
header('Location: '.PHPCI_URL.'project/view/'.$projectId);
die;
$response = new b8\Http\Response\RedirectResponse();
$response->setHeader('Location', PHPCI_URL.'project/view/'.$projectId);
return $response;
}
$this->view->builds = $builds[0];
@ -118,8 +119,9 @@ class ProjectController extends \PHPCI\Controller
$email = $_SESSION['phpci_user']->getEmail();
$build = $this->buildService->createBuild($project, null, urldecode($branch), $email);
header('Location: '.PHPCI_URL.'build/view/' . $build->getId());
exit;
$response = new b8\Http\Response\RedirectResponse();
$response->setHeader('Location', PHPCI_URL.'build/view/' . $build->getId());
return $response;
}
/**
@ -132,8 +134,9 @@ class ProjectController extends \PHPCI\Controller
$project = $this->projectStore->getById($projectId);
$this->projectService->deleteProject($project);
header('Location: '.PHPCI_URL);
exit;
$response = new b8\Http\Response\RedirectResponse();
$response->setHeader('Location', PHPCI_URL);
return $response;
}
/**
@ -143,7 +146,9 @@ class ProjectController extends \PHPCI\Controller
{
$branch = $this->getParam('branch', '');
$builds = $this->getLatestBuildsHtml($projectId, urldecode($branch));
die($builds[0]);
$this->response->setContent($builds[0]);
return $this->response;
}
/**
@ -220,8 +225,10 @@ class ProjectController extends \PHPCI\Controller
);
$project = $this->projectService->createProject($title, $type, $reference, $options);
header('Location: '.PHPCI_URL.'project/view/' . $project->getId());
die;
$response = new b8\Http\Response\RedirectResponse();
$response->setHeader('Location', PHPCI_URL.'project/view/' . $project->getId());
return $response;
}
}
@ -282,8 +289,9 @@ class ProjectController extends \PHPCI\Controller
$project = $this->projectService->updateProject($project, $title, $type, $reference, $options);
header('Location: '.PHPCI_URL.'project/view/' . $project->getId());
die;
$response = new b8\Http\Response\RedirectResponse();
$response->setHeader('Location', PHPCI_URL.'project/view/' . $project->getId());
return $response;
}
/**
@ -366,7 +374,10 @@ class ProjectController extends \PHPCI\Controller
protected function githubRepositories()
{
$github = new Github();
die(json_encode($github->getRepositories()));
$response = new b8\Http\Response\JsonResponse();
$response->setContent($github->getRepositories());
return $response;
}
/**