1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-04-10 03:18:41 +02:00
phorge-phorge/src/applications/releeph/controller/branch/ReleephBranchEditController.php
epriestley a5dc9067af Provide convenience method addTextCrumb() to PhabricatorCrumbsView
Summary: We currently have a lot of calls to `addCrumb(id(new PhabricatorCrumbView())->...)` which can be expressed much more simply with a convenience method. Nearly all crumbs are only textual.

Test Plan:
  - This was mostly automated, then I cleaned up a few unusual sites manually.
  - Bunch of grep / randomly clicking around.

Reviewers: btrahan, chad

Reviewed By: btrahan

CC: hach-que, aran

Differential Revision: https://secure.phabricator.com/D7787
2013-12-18 17:47:34 -08:00

102 lines
2.9 KiB
PHP

<?php
final class ReleephBranchEditController extends ReleephProjectController {
public function processRequest() {
$request = $this->getRequest();
$releeph_branch = $this->getReleephBranch();
$symbolic_name = $request->getStr(
'symbolicName',
$releeph_branch->getSymbolicName());
$errors = array();
if ($request->isFormPost()) {
$existing_with_same_symbolic_name =
id(new ReleephBranch())
->loadOneWhere(
'id != %d AND releephProjectID = %d AND symbolicName = %s',
$releeph_branch->getID(),
$releeph_branch->getReleephProjectID(),
$symbolic_name);
$releeph_branch->openTransaction();
$releeph_branch
->setSymbolicName($symbolic_name);
if ($existing_with_same_symbolic_name) {
$existing_with_same_symbolic_name
->setSymbolicName(null)
->save();
}
$releeph_branch->save();
$releeph_branch->saveTransaction();
return id(new AphrontRedirectResponse())
->setURI($releeph_branch->getURI());
}
$phids = array();
$phids[] = $creator_phid = $releeph_branch->getCreatedByUserPHID();
$phids[] = $cut_commit_phid = $releeph_branch->getCutPointCommitPHID();
$handles = id(new PhabricatorHandleQuery())
->setViewer($request->getUser())
->withPHIDs($phids)
->execute();
$form = id(new AphrontFormView())
->setUser($request->getUser())
->appendChild(
id(new AphrontFormStaticControl())
->setLabel(pht('Branch Name'))
->setValue($releeph_branch->getName()))
->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Cut Point'))
->setValue($handles[$cut_commit_phid]->renderLink()))
->appendChild(
id(new AphrontFormMarkupControl())
->setLabel(pht('Created By'))
->setValue($handles[$creator_phid]->renderLink()))
->appendChild(
id(new AphrontFormTextControl)
->setLabel(pht('Symbolic Name'))
->setName('symbolicName')
->setValue($symbolic_name)
->setCaption(pht('Mutable alternate name, for easy reference, '.
'(e.g. "LATEST")')))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($releeph_branch->getURI())
->setValue(pht('Save')));
$error_view = null;
if ($errors) {
$error_view = id(new AphrontErrorView())
->setSeverity(AphrontErrorView::SEVERITY_ERROR)
->setErrors($errors)
->setTitle(pht('Errors'));
}
$title = pht(
'Edit Branch %s',
$releeph_branch->getDisplayNameWithDetail());
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Edit'));
return $this->buildApplicationPage(
array(
$crumbs,
$error_view,
$form,
),
array(
'title' => $title,
'device' => true,
));
}
}