[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/releeph/controller/request/ -> ReleephRequestViewController.php (source)

   1  <?php
   2  
   3  final class ReleephRequestViewController
   4    extends ReleephBranchController {
   5  
   6    private $requestID;
   7  
   8    public function willProcessRequest(array $data) {
   9      $this->requestID = $data['requestID'];
  10    }
  11  
  12    public function processRequest() {
  13      $request = $this->getRequest();
  14      $viewer = $request->getUser();
  15  
  16      $pull = id(new ReleephRequestQuery())
  17        ->setViewer($viewer)
  18        ->withIDs(array($this->requestID))
  19        ->executeOne();
  20      if (!$pull) {
  21        return new Aphront404Response();
  22      }
  23      $this->setBranch($pull->getBranch());
  24  
  25      // Redirect older URIs to new "Y" URIs.
  26      // TODO: Get rid of this eventually.
  27      $actual_path = $request->getRequestURI()->getPath();
  28      $expect_path = '/'.$pull->getMonogram();
  29      if ($actual_path != $expect_path) {
  30        return id(new AphrontRedirectResponse())->setURI($expect_path);
  31      }
  32  
  33      // TODO: Break this 1:1 stuff?
  34      $branch = $pull->getBranch();
  35  
  36      $field_list = PhabricatorCustomField::getObjectFields(
  37        $pull,
  38        PhabricatorCustomField::ROLE_VIEW);
  39  
  40      $field_list
  41        ->setViewer($viewer)
  42        ->readFieldsFromStorage($pull);
  43  
  44      // TODO: This should be more modern and general.
  45      $engine = id(new PhabricatorMarkupEngine())
  46        ->setViewer($viewer);
  47      foreach ($field_list->getFields() as $field) {
  48        if ($field->shouldMarkup()) {
  49          $field->setMarkupEngine($engine);
  50        }
  51      }
  52      $engine->process();
  53  
  54      $pull_box = id(new ReleephRequestView())
  55        ->setUser($viewer)
  56        ->setCustomFields($field_list)
  57        ->setPullRequest($pull);
  58  
  59      $xactions = id(new ReleephRequestTransactionQuery())
  60        ->setViewer($viewer)
  61        ->withObjectPHIDs(array($pull->getPHID()))
  62        ->execute();
  63  
  64      $timeline = id(new PhabricatorApplicationTransactionView())
  65        ->setUser($request->getUser())
  66        ->setObjectPHID($pull->getPHID())
  67        ->setTransactions($xactions);
  68  
  69      $add_comment_header = pht('Plea or Yield');
  70  
  71      $draft = PhabricatorDraft::newFromUserAndKey(
  72        $viewer,
  73        $pull->getPHID());
  74  
  75      $title = hsprintf(
  76        '%s %s',
  77        $pull->getMonogram(),
  78        $pull->getSummaryForDisplay());
  79  
  80      $add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
  81        ->setUser($viewer)
  82        ->setObjectPHID($pull->getPHID())
  83        ->setDraft($draft)
  84        ->setHeaderText($add_comment_header)
  85        ->setAction($this->getApplicationURI(
  86          '/request/comment/'.$pull->getID().'/'))
  87        ->setSubmitButtonName(pht('Comment'));
  88  
  89      $crumbs = $this->buildApplicationCrumbs();
  90      $crumbs->addTextCrumb($pull->getMonogram(), '/'.$pull->getMonogram());
  91  
  92      return $this->buildStandardPageResponse(
  93        array(
  94          $crumbs,
  95          $pull_box,
  96          $timeline,
  97          $add_comment_form,
  98        ),
  99        array(
 100          'title' => $title,
 101          'device' => true,
 102        ));
 103    }
 104  
 105  
 106  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1