1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-15 11:22:40 +01:00
phorge-phorge/src/applications/diffusion/controller/DiffusionRepositoryNewController.php
Bob Trahan a823654be0 Diffusion - return 404 errors for bad URIs
Summary: Fixes T5646. Makes diffusion a much better user experience. Users now see a 404 exception page when they have a bad URI. Previously, they saw a developer-facing raw exception.

Test Plan: played around in diffusion a bunch. most of these changes were fairly mechanical at the end of the day.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T5646

Differential Revision: https://secure.phabricator.com/D11299
2015-01-09 13:29:08 -08:00

83 lines
2.5 KiB
PHP

<?php
final class DiffusionRepositoryNewController extends DiffusionController {
protected function processDiffusionRequest(AphrontRequest $request) {
$viewer = $request->getUser();
$this->requireApplicationCapability(
DiffusionCreateRepositoriesCapability::CAPABILITY);
if ($request->isFormPost()) {
if ($request->getStr('type')) {
switch ($request->getStr('type')) {
case 'create':
$uri = $this->getApplicationURI('create/');
break;
case 'import':
default:
$uri = $this->getApplicationURI('import/');
break;
}
return id(new AphrontRedirectResponse())->setURI($uri);
}
}
$doc_href = PhabricatorEnv::getDoclink(
'Diffusion User Guide: Repository Hosting');
$doc_link = phutil_tag(
'a',
array(
'href' => $doc_href,
'target' => '_blank',
),
pht('Diffusion User Guide: Repository Hosting'));
$form = id(new AphrontFormView())
->setUser($viewer)
->appendChild(
id(new AphrontFormRadioButtonControl())
->setName('type')
->addButton(
'create',
pht('Create a New Hosted Repository'),
array(
pht(
'Create a new, empty repository which Phabricator will host. '.
'For instructions on configuring repository hosting, see %s.',
$doc_link),
))
->addButton(
'import',
pht('Import an Existing External Repository'),
pht(
'Import a repository hosted somewhere else, like GitHub, '.
'Bitbucket, or your organization\'s existing servers. '.
'Phabricator will read changes from the repository but will '.
'not host or manage it. The authoritative master version of '.
'the repository will stay where it is now.')))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Continue'))
->addCancelButton($this->getApplicationURI()));
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('New Repository'));
$form_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Create or Import Repository'))
->setForm($form);
return $this->buildApplicationPage(
array(
$crumbs,
$form_box,
),
array(
'title' => pht('New Repository'),
));
}
}