Differential D11692 Diff 28134 src/applications/harbormaster/storage/build/HarbormasterBuildItem.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/storage/build/HarbormasterBuildItem.php
<?php | <?php | ||||
final class HarbormasterBuildItem extends HarbormasterDAO { | final class HarbormasterBuildItem extends HarbormasterDAO | ||||
implements PhabricatorPolicyInterface { | |||||
protected $name; | protected $name; | ||||
protected $buildTargetPHID; | |||||
protected $type; | |||||
protected $details = array(); | |||||
private $buildTarget = self::ATTACHABLE; | |||||
const TYPE_UNIT = 'unit'; | |||||
const TYPE_LINT = 'lint'; | |||||
public static function initializeNewBuildItem( | |||||
HarbormasterBuildTarget $build_target, | |||||
$type) { | |||||
return id(new HarbormasterBuildItem()) | |||||
->setBuildTargetPHID($build_target->getPHID()) | |||||
->setType($type); | |||||
} | |||||
protected function getConfiguration() { | protected function getConfiguration() { | ||||
return array( | return array( | ||||
self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
self::CONFIG_NO_TABLE => true, | self::CONFIG_SERIALIZATION => array( | ||||
'details' => self::SERIALIZATION_JSON, | |||||
), | |||||
self::CONFIG_COLUMN_SCHEMA => array( | |||||
'type' => 'text32', | |||||
'name' => 'text255', | |||||
), | |||||
self::CONFIG_KEY_SCHEMA => array( | |||||
'key_type' => array( | |||||
'columns' => array('buildTargetPHID', 'type'), | |||||
), | |||||
), | |||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function attachBuildTarget(HarbormasterBuildTarget $build_target) { | |||||
$this->buildTarget = $build_target; | |||||
return $this; | |||||
} | |||||
public function getBuildTarget() { | |||||
return $this->assertAttached($this->buildTarget); | |||||
} | |||||
public function generatePHID() { | public function generatePHID() { | ||||
return PhabricatorPHID::generateNewPHID( | return PhabricatorPHID::generateNewPHID( | ||||
HarbormasterBuildItemPHIDType::TYPECONST); | HarbormasterBuildItemPHIDType::TYPECONST); | ||||
} | } | ||||
public function getResult() { | |||||
return idx($this->getDetails(), 'result'); | |||||
} | |||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | |||||
public function getCapabilities() { | |||||
return array( | |||||
PhabricatorPolicyCapability::CAN_VIEW, | |||||
); | |||||
} | |||||
public function getPolicy($capability) { | |||||
return $this->getBuildTarget()->getPolicy($capability); | |||||
} | |||||
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | |||||
return $this->getBuildTarget()->hasAutomaticCapability( | |||||
$capability, | |||||
$viewer); | |||||
} | |||||
public function describeAutomaticCapability($capability) { | |||||
return pht( | |||||
'Users must be able to see a buildable to see its artifacts.'); | |||||
} | |||||
} | } |