[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/differential/view/ -> DifferentialRevisionDetailView.php (source)

   1  <?php
   2  
   3  final class DifferentialRevisionDetailView extends AphrontView {
   4  
   5    private $revision;
   6    private $actions;
   7    private $customFields;
   8    private $diff;
   9    private $uri;
  10    private $actionList;
  11  
  12    public function setURI($uri) {
  13      $this->uri = $uri;
  14      return $this;
  15    }
  16    public function getURI() {
  17      return $this->uri;
  18    }
  19  
  20    public function setDiff(DifferentialDiff $diff) {
  21      $this->diff = $diff;
  22      return $this;
  23    }
  24    private function getDiff() {
  25      return $this->diff;
  26    }
  27  
  28    public function setRevision(DifferentialRevision $revision) {
  29      $this->revision = $revision;
  30      return $this;
  31    }
  32  
  33    public function setActions(array $actions) {
  34      $this->actions = $actions;
  35      return $this;
  36    }
  37    private function getActions() {
  38      return $this->actions;
  39    }
  40  
  41    public function setActionList(PhabricatorActionListView $list) {
  42      $this->actionList = $list;
  43      return $this;
  44    }
  45  
  46    public function getActionList() {
  47      return $this->actionList;
  48    }
  49  
  50    public function setCustomFields(PhabricatorCustomFieldList $list) {
  51      $this->customFields = $list;
  52      return $this;
  53    }
  54  
  55    public function render() {
  56  
  57      $this->requireResource('differential-core-view-css');
  58  
  59      $revision = $this->revision;
  60      $user = $this->getUser();
  61  
  62      $header = $this->renderHeader($revision);
  63  
  64      $actions = id(new PhabricatorActionListView())
  65        ->setUser($user)
  66        ->setObject($revision)
  67        ->setObjectURI($this->getURI());
  68      foreach ($this->getActions() as $action) {
  69        $actions->addAction($action);
  70      }
  71  
  72      $properties = id(new PHUIPropertyListView())
  73        ->setUser($user)
  74        ->setObject($revision);
  75  
  76      $status = $revision->getStatus();
  77      $local_vcs = $this->getDiff()->getSourceControlSystem();
  78  
  79      $next_step = null;
  80      if ($status == ArcanistDifferentialRevisionStatus::ACCEPTED) {
  81        switch ($local_vcs) {
  82          case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
  83            $bookmark = $this->getDiff()->getBookmark();
  84            $next_step = ($bookmark != ''
  85              ? csprintf('arc land %s', $bookmark)
  86              : 'arc land');
  87            break;
  88  
  89          case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
  90            $branch = $this->getDiff()->getBranch();
  91            $next_step = ($branch != ''
  92              ? csprintf('arc land %s', $branch)
  93              : 'arc land');
  94            break;
  95  
  96          case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
  97            $next_step = 'arc commit';
  98            break;
  99        }
 100      }
 101      if ($next_step) {
 102        $next_step = phutil_tag('tt', array(), $next_step);
 103        $properties->addProperty(pht('Next Step'), $next_step);
 104      }
 105  
 106      $properties->setHasKeyboardShortcuts(true);
 107      $properties->setActionList($actions);
 108      $this->setActionList($actions);
 109  
 110      $field_list = $this->customFields;
 111      if ($field_list) {
 112        $field_list->appendFieldsToPropertyList(
 113          $revision,
 114          $user,
 115          $properties);
 116      }
 117  
 118      $object_box = id(new PHUIObjectBoxView())
 119        ->setHeader($header)
 120        ->addPropertyList($properties);
 121  
 122      return $object_box;
 123    }
 124  
 125    private function renderHeader(DifferentialRevision $revision) {
 126      $view = id(new PHUIHeaderView())
 127        ->setHeader($revision->getTitle($revision))
 128        ->setUser($this->getUser())
 129        ->setPolicyObject($revision);
 130  
 131      $status = $revision->getStatus();
 132      $status_name =
 133        DifferentialRevisionStatus::renderFullDescription($status);
 134  
 135      $view->addProperty(PHUIHeaderView::PROPERTY_STATUS, $status_name);
 136  
 137      return $view;
 138    }
 139  
 140    public static function renderTagForRevision(
 141      DifferentialRevision $revision) {
 142  
 143      $status = $revision->getStatus();
 144      $status_name =
 145        ArcanistDifferentialRevisionStatus::getNameForRevisionStatus($status);
 146  
 147      return id(new PHUITagView())
 148        ->setType(PHUITagView::TYPE_STATE)
 149        ->setName($status_name);
 150    }
 151  
 152  }


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