[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/harbormaster/storage/configuration/ -> HarbormasterBuildStep.php (source)

   1  <?php
   2  
   3  final class HarbormasterBuildStep extends HarbormasterDAO
   4    implements
   5      PhabricatorPolicyInterface,
   6      PhabricatorCustomFieldInterface {
   7  
   8    protected $name;
   9    protected $description;
  10    protected $buildPlanPHID;
  11    protected $className;
  12    protected $details = array();
  13    protected $sequence = 0;
  14  
  15    private $buildPlan = self::ATTACHABLE;
  16    private $customFields = self::ATTACHABLE;
  17    private $implementation;
  18  
  19    public static function initializeNewStep(PhabricatorUser $actor) {
  20      return id(new HarbormasterBuildStep());
  21    }
  22  
  23    public function getConfiguration() {
  24      return array(
  25        self::CONFIG_AUX_PHID => true,
  26        self::CONFIG_SERIALIZATION => array(
  27          'details' => self::SERIALIZATION_JSON,
  28        ),
  29        self::CONFIG_COLUMN_SCHEMA => array(
  30          'className' => 'text255',
  31          'sequence' => 'uint32',
  32          'description' => 'text',
  33  
  34          // T6203/NULLABILITY
  35          // This should not be nullable. Current `null` values indicate steps
  36          // which predated editable names. These should be backfilled with
  37          // default names, then the code for handling `null` shoudl be removed.
  38          'name' => 'text255?',
  39        ),
  40        self::CONFIG_KEY_SCHEMA => array(
  41          'key_plan' => array(
  42            'columns' => array('buildPlanPHID'),
  43          ),
  44        ),
  45      ) + parent::getConfiguration();
  46    }
  47  
  48    public function generatePHID() {
  49      return PhabricatorPHID::generateNewPHID(
  50        HarbormasterBuildStepPHIDType::TYPECONST);
  51    }
  52  
  53    public function attachBuildPlan(HarbormasterBuildPlan $plan) {
  54      $this->buildPlan = $plan;
  55      return $this;
  56    }
  57  
  58    public function getBuildPlan() {
  59      return $this->assertAttached($this->buildPlan);
  60    }
  61  
  62    public function getDetail($key, $default = null) {
  63      return idx($this->details, $key, $default);
  64    }
  65  
  66    public function setDetail($key, $value) {
  67      $this->details[$key] = $value;
  68      return $this;
  69    }
  70  
  71    public function getName() {
  72      if (strlen($this->name)) {
  73        return $this->name;
  74      }
  75  
  76      return $this->getStepImplementation()->getName();
  77    }
  78  
  79    public function getStepImplementation() {
  80      if ($this->implementation === null) {
  81        $obj = HarbormasterBuildStepImplementation::requireImplementation(
  82          $this->className);
  83        $obj->loadSettings($this);
  84        $this->implementation = $obj;
  85      }
  86  
  87      return $this->implementation;
  88    }
  89  
  90  
  91  /* -(  PhabricatorPolicyInterface  )----------------------------------------- */
  92  
  93  
  94    public function getCapabilities() {
  95      return array(
  96        PhabricatorPolicyCapability::CAN_VIEW,
  97      );
  98    }
  99  
 100    public function getPolicy($capability) {
 101      return $this->getBuildPlan()->getPolicy($capability);
 102    }
 103  
 104    public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
 105      return $this->getBuildPlan()->hasAutomaticCapability($capability, $viewer);
 106    }
 107  
 108    public function describeAutomaticCapability($capability) {
 109      return pht('A build step has the same policies as its build plan.');
 110    }
 111  
 112  
 113  /* -(  PhabricatorCustomFieldInterface  )------------------------------------ */
 114  
 115  
 116    public function getCustomFieldSpecificationForRole($role) {
 117      return array();
 118    }
 119  
 120    public function getCustomFieldBaseClass() {
 121      return 'HarbormasterBuildStepCustomField';
 122    }
 123  
 124    public function getCustomFields() {
 125      return $this->assertAttached($this->customFields);
 126    }
 127  
 128    public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) {
 129      $this->customFields = $fields;
 130      return $this;
 131    }
 132  
 133  
 134  }


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