[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/differential/customfield/ -> DifferentialBranchField.php (source)

   1  <?php
   2  
   3  final class DifferentialBranchField
   4    extends DifferentialCustomField {
   5  
   6    public function getFieldKey() {
   7      return 'differential:branch';
   8    }
   9  
  10    public function getFieldName() {
  11      return pht('Branch');
  12    }
  13  
  14    public function getFieldDescription() {
  15      return pht('Shows the branch a diff came from.');
  16    }
  17  
  18    public function shouldAppearInPropertyView() {
  19      return true;
  20    }
  21  
  22    public function renderPropertyViewLabel() {
  23      return $this->getFieldName();
  24    }
  25  
  26    public function renderPropertyViewValue(array $handles) {
  27      return $this->getBranchDescription($this->getObject()->getActiveDiff());
  28    }
  29  
  30    private function getBranchDescription(DifferentialDiff $diff) {
  31      $branch = $diff->getBranch();
  32      $bookmark = $diff->getBookmark();
  33  
  34      if (strlen($branch) && strlen($bookmark)) {
  35        return pht('%s (bookmark) on %s (branch)', $bookmark, $branch);
  36      } else if (strlen($bookmark)) {
  37        return pht('%s (bookmark)', $bookmark);
  38      } else if (strlen($branch)) {
  39        return $branch;
  40      } else {
  41        return null;
  42      }
  43    }
  44  
  45    public function getProTips() {
  46      return array(
  47        pht(
  48          'In Git and Mercurial, use a branch like "T123" to automatically '.
  49          'associate changes with the corresponding task.'),
  50      );
  51    }
  52  
  53    public function shouldAppearInTransactionMail() {
  54      return true;
  55    }
  56  
  57    public function updateTransactionMailBody(
  58      PhabricatorMetaMTAMailBody $body,
  59      PhabricatorApplicationTransactionEditor $editor,
  60      array $xactions) {
  61  
  62      $status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED;
  63  
  64      // Show the "BRANCH" section only if there's a new diff or the revision
  65      // is "Accepted".
  66      if ((!$editor->getDiffUpdateTransaction($xactions)) &&
  67          ($this->getObject()->getStatus() != $status_accepted)) {
  68        return;
  69      }
  70  
  71      $branch = $this->getBranchDescription($this->getObject()->getActiveDiff());
  72      if ($branch === null) {
  73        return;
  74      }
  75  
  76      $body->addTextSection(pht('BRANCH'), $branch);
  77    }
  78  
  79  }


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