[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/diffusion/herald/ -> HeraldPreCommitRefAdapter.php (source)

   1  <?php
   2  
   3  final class HeraldPreCommitRefAdapter extends HeraldPreCommitAdapter {
   4  
   5    const FIELD_REF_TYPE = 'ref-type';
   6    const FIELD_REF_NAME = 'ref-name';
   7    const FIELD_REF_CHANGE = 'ref-change';
   8  
   9    const VALUE_REF_TYPE = 'value-ref-type';
  10    const VALUE_REF_CHANGE = 'value-ref-change';
  11  
  12    public function getAdapterContentName() {
  13      return pht('Commit Hook: Branches/Tags/Bookmarks');
  14    }
  15  
  16    public function getAdapterSortOrder() {
  17      return 2000;
  18    }
  19  
  20    public function getAdapterContentDescription() {
  21      return pht(
  22        "React to branches and tags being pushed to hosted repositories.\n".
  23        "Hook rules can block changes and send push summary mail.");
  24    }
  25  
  26    public function getFieldNameMap() {
  27      return array(
  28        self::FIELD_REF_TYPE => pht('Ref type'),
  29        self::FIELD_REF_NAME => pht('Ref name'),
  30        self::FIELD_REF_CHANGE => pht('Ref change type'),
  31      ) + parent::getFieldNameMap();
  32    }
  33  
  34    public function getFields() {
  35      return array_merge(
  36        array(
  37          self::FIELD_REF_TYPE,
  38          self::FIELD_REF_NAME,
  39          self::FIELD_REF_CHANGE,
  40          self::FIELD_REPOSITORY,
  41          self::FIELD_REPOSITORY_PROJECTS,
  42          self::FIELD_PUSHER,
  43          self::FIELD_PUSHER_PROJECTS,
  44        ),
  45        parent::getFields());
  46    }
  47  
  48    public function getConditionsForField($field) {
  49      switch ($field) {
  50        case self::FIELD_REF_NAME:
  51          return array(
  52            self::CONDITION_IS,
  53            self::CONDITION_IS_NOT,
  54            self::CONDITION_CONTAINS,
  55            self::CONDITION_REGEXP,
  56          );
  57        case self::FIELD_REF_TYPE:
  58          return array(
  59            self::CONDITION_IS,
  60            self::CONDITION_IS_NOT,
  61          );
  62        case self::FIELD_REF_CHANGE:
  63          return array(
  64            self::CONDITION_HAS_BIT,
  65            self::CONDITION_NOT_BIT,
  66          );
  67      }
  68      return parent::getConditionsForField($field);
  69    }
  70  
  71    public function getValueTypeForFieldAndCondition($field, $condition) {
  72      switch ($field) {
  73        case self::FIELD_REF_TYPE:
  74          return self::VALUE_REF_TYPE;
  75        case self::FIELD_REF_CHANGE:
  76          return self::VALUE_REF_CHANGE;
  77      }
  78  
  79      return parent::getValueTypeForFieldAndCondition($field, $condition);
  80    }
  81  
  82    public function getHeraldName() {
  83      return pht('Push Log (Ref)');
  84    }
  85  
  86    public function getHeraldField($field) {
  87      $log = $this->getObject();
  88      switch ($field) {
  89        case self::FIELD_REF_TYPE:
  90          return $log->getRefType();
  91        case self::FIELD_REF_NAME:
  92          return $log->getRefName();
  93        case self::FIELD_REF_CHANGE:
  94          return $log->getChangeFlags();
  95        case self::FIELD_REPOSITORY:
  96          return $this->getHookEngine()->getRepository()->getPHID();
  97        case self::FIELD_REPOSITORY_PROJECTS:
  98          return $this->getHookEngine()->getRepository()->getProjectPHIDs();
  99        case self::FIELD_PUSHER:
 100          return $this->getHookEngine()->getViewer()->getPHID();
 101        case self::FIELD_PUSHER_PROJECTS:
 102          return $this->getHookEngine()->loadViewerProjectPHIDsForHerald();
 103      }
 104  
 105      return parent::getHeraldField($field);
 106    }
 107  
 108  }


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