Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / releeph / controller / request / ReleephRequestViewController.php
blobc404e315790cbbbb0e35f52b5619cf9389efdf6f
1 <?php
3 final class ReleephRequestViewController
4 extends ReleephBranchController {
6 public function handleRequest(AphrontRequest $request) {
7 $id = $request->getURIData('requestID');
8 $viewer = $request->getViewer();
10 $pull = id(new ReleephRequestQuery())
11 ->setViewer($viewer)
12 ->withIDs(array($id))
13 ->executeOne();
14 if (!$pull) {
15 return new Aphront404Response();
17 $this->setBranch($pull->getBranch());
19 // Redirect older URIs to new "Y" URIs.
20 // TODO: Get rid of this eventually.
21 $actual_path = $request->getRequestURI()->getPath();
22 $expect_path = '/'.$pull->getMonogram();
23 if ($actual_path != $expect_path) {
24 return id(new AphrontRedirectResponse())->setURI($expect_path);
27 // TODO: Break this 1:1 stuff?
28 $branch = $pull->getBranch();
30 $field_list = PhabricatorCustomField::getObjectFields(
31 $pull,
32 PhabricatorCustomField::ROLE_VIEW);
34 $field_list
35 ->setViewer($viewer)
36 ->readFieldsFromStorage($pull);
38 // TODO: This should be more modern and general.
39 $engine = id(new PhabricatorMarkupEngine())
40 ->setViewer($viewer);
41 foreach ($field_list->getFields() as $field) {
42 if ($field->shouldMarkup()) {
43 $field->setMarkupEngine($engine);
46 $engine->process();
48 $pull_box = id(new ReleephRequestView())
49 ->setUser($viewer)
50 ->setCustomFields($field_list)
51 ->setPullRequest($pull);
53 $timeline = $this->buildTransactionTimeline(
54 $pull,
55 new ReleephRequestTransactionQuery());
57 $add_comment_header = pht('Plea or Yield');
59 $draft = PhabricatorDraft::newFromUserAndKey(
60 $viewer,
61 $pull->getPHID());
63 $title = hsprintf(
64 '%s %s',
65 $pull->getMonogram(),
66 $pull->getSummaryForDisplay());
68 $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
69 ->setUser($viewer)
70 ->setObjectPHID($pull->getPHID())
71 ->setDraft($draft)
72 ->setHeaderText($add_comment_header)
73 ->setAction($this->getApplicationURI(
74 '/request/comment/'.$pull->getID().'/'))
75 ->setSubmitButtonName(pht('Comment'));
77 $crumbs = $this->buildApplicationCrumbs();
78 $crumbs->addTextCrumb($pull->getMonogram(), '/'.$pull->getMonogram());
79 $crumbs->setBorder(true);
81 $header = id(new PHUIHeaderView())
82 ->setHeader($title)
83 ->setHeaderIcon('fa-flag-checkered');
85 $view = id(new PHUITwoColumnView())
86 ->setHeader($header)
87 ->setFooter(array(
88 $pull_box,
89 $timeline,
90 $add_comment_form,
91 ));
93 return $this->newPage()
94 ->setTitle($title)
95 ->setCrumbs($crumbs)
96 ->appendChild($view);