[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

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

   1  <?php
   2  
   3  /**
   4   * @task commitmessage    Integration with Commit Messages
   5   */
   6  abstract class DifferentialCustomField
   7    extends PhabricatorCustomField {
   8  
   9    const ROLE_COMMITMESSAGE      = 'differential:commitmessage';
  10    const ROLE_COMMITMESSAGEEDIT  = 'differential:commitmessageedit';
  11  
  12    /**
  13     * TODO: It would be nice to remove this, but a lot of different code is
  14     * bound together by it. Until everything is modernized, retaining the old
  15     * field keys is the only reasonable way to update things one piece
  16     * at a time.
  17     */
  18    public function getFieldKeyForConduit() {
  19      return $this->getFieldKey();
  20    }
  21  
  22    public function shouldEnableForRole($role) {
  23      switch ($role) {
  24        case self::ROLE_COMMITMESSAGE:
  25          return $this->shouldAppearInCommitMessage();
  26        case self::ROLE_COMMITMESSAGEEDIT:
  27          return $this->shouldAppearInCommitMessage() &&
  28                 $this->shouldAllowEditInCommitMessage();
  29      }
  30  
  31      return parent::shouldEnableForRole($role);
  32    }
  33  
  34    public function getRequiredDiffPropertiesForRevisionView() {
  35      if ($this->getProxy()) {
  36        return $this->getProxy()->getRequiredDiffPropertiesForRevisionView();
  37      }
  38      return array();
  39    }
  40  
  41    protected function parseObjectList(
  42      $value,
  43      array $types,
  44      $allow_partial = false) {
  45      return id(new PhabricatorObjectListQuery())
  46        ->setViewer($this->getViewer())
  47        ->setAllowedTypes($types)
  48        ->setObjectList($value)
  49        ->setAllowPartialResults($allow_partial)
  50        ->execute();
  51    }
  52  
  53    protected function renderObjectList(array $handles) {
  54      if (!$handles) {
  55        return null;
  56      }
  57  
  58      $out = array();
  59      foreach ($handles as $handle) {
  60        if ($handle->getPolicyFiltered()) {
  61          $out[] = $handle->getPHID();
  62        } else if ($handle->isComplete()) {
  63          $out[] = $handle->getObjectName();
  64        }
  65      }
  66  
  67      return implode(', ', $out);
  68    }
  69  
  70    public function getWarningsForDetailView() {
  71      if ($this->getProxy()) {
  72        return $this->getProxy()->getWarningsForDetailView();
  73      }
  74      return array();
  75    }
  76  
  77    public function getRequiredHandlePHIDsForRevisionHeaderWarnings() {
  78      return array();
  79    }
  80  
  81    public function getWarningsForRevisionHeader(array $handles) {
  82      return array();
  83    }
  84  
  85  /* -(  Integration with Commit Messages  )----------------------------------- */
  86  
  87  
  88    /**
  89     * @task commitmessage
  90     */
  91    public function shouldAppearInCommitMessage() {
  92      if ($this->getProxy()) {
  93        return $this->getProxy()->shouldAppearInCommitMessage();
  94      }
  95      return false;
  96    }
  97  
  98  
  99    /**
 100     * @task commitmessage
 101     */
 102    public function shouldAppearInCommitMessageTemplate() {
 103      if ($this->getProxy()) {
 104        return $this->getProxy()->shouldAppearInCommitMessageTemplate();
 105      }
 106      return false;
 107    }
 108  
 109  
 110    /**
 111     * @task commitmessage
 112     */
 113    public function shouldAllowEditInCommitMessage() {
 114      if ($this->getProxy()) {
 115        return $this->getProxy()->shouldAllowEditInCommitMessage();
 116      }
 117      return true;
 118    }
 119  
 120  
 121    /**
 122     * @task commitmessage
 123     */
 124    public function getProTips() {
 125      if ($this->getProxy()) {
 126        return $this->getProxy()->getProTips();
 127      }
 128      return array();
 129    }
 130  
 131  
 132    /**
 133     * @task commitmessage
 134     */
 135    public function getCommitMessageLabels() {
 136      if ($this->getProxy()) {
 137        return $this->getProxy()->getCommitMessageLabels();
 138      }
 139      return array($this->renderCommitMessageLabel());
 140    }
 141  
 142  
 143    /**
 144     * @task commitmessage
 145     */
 146    public function parseValueFromCommitMessage($value) {
 147      if ($this->getProxy()) {
 148        return $this->getProxy()->parseValueFromCommitMessage($value);
 149      }
 150      return $value;
 151    }
 152  
 153  
 154    /**
 155     * @task commitmessage
 156     */
 157    public function readValueFromCommitMessage($value) {
 158      if ($this->getProxy()) {
 159        $this->getProxy()->readValueFromCommitMessage($value);
 160        return $this;
 161      }
 162      return $this;
 163    }
 164  
 165  
 166    /**
 167     * @task commitmessage
 168     */
 169    public function shouldOverwriteWhenCommitMessageIsEdited() {
 170      if ($this->getProxy()) {
 171        return $this->getProxy()->shouldOverwriteWhenCommitMessageIsEdited();
 172      }
 173      return false;
 174    }
 175  
 176  
 177    /**
 178     * @task commitmessage
 179     */
 180    public function getRequiredHandlePHIDsForCommitMessage() {
 181      if ($this->getProxy()) {
 182        return $this->getProxy()->getRequiredHandlePHIDsForCommitMessage();
 183      }
 184      return array();
 185    }
 186  
 187  
 188    /**
 189     * @task commitmessage
 190     */
 191    public function renderCommitMessageLabel() {
 192      if ($this->getProxy()) {
 193        return $this->getProxy()->renderCommitMessageLabel();
 194      }
 195      return $this->getFieldName();
 196    }
 197  
 198  
 199    /**
 200     * @task commitmessage
 201     */
 202    public function renderCommitMessageValue(array $handles) {
 203      if ($this->getProxy()) {
 204        return $this->getProxy()->renderCommitMessageValue($handles);
 205      }
 206      throw new PhabricatorCustomFieldImplementationIncompleteException($this);
 207    }
 208  
 209  
 210    /**
 211     * @task commitmessage
 212     */
 213    public function validateCommitMessageValue($value) {
 214      if ($this->getProxy()) {
 215        return $this->getProxy()->validateCommitMessageValue($value);
 216      }
 217      return;
 218    }
 219  
 220  }


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