Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/storage/build/HarbormasterBuild.php
- This file was added.
<?php | |||||
final class HarbormasterBuild extends HarbormasterDAO | |||||
implements PhabricatorPolicyInterface { | |||||
protected $buildablePHID; | |||||
protected $buildPlanPHID; | |||||
protected $buildStatus; | |||||
private $buildable = self::ATTACHABLE; | |||||
private $buildPlan = self::ATTACHABLE; | |||||
public static function initializeNewBuild(PhabricatorUser $actor) { | |||||
return id(new HarbormasterBuild()) | |||||
->setBuildStatus('building'); // TODO: Sort this. | |||||
} | |||||
public function getConfiguration() { | |||||
return array( | |||||
self::CONFIG_AUX_PHID => true, | |||||
) + parent::getConfiguration(); | |||||
} | |||||
public function generatePHID() { | |||||
return PhabricatorPHID::generateNewPHID( | |||||
HarbormasterPHIDTypeBuildPlan::TYPECONST); | |||||
} | |||||
public function attachBuildable(HarbormasterBuildable $buildable) { | |||||
$this->buildable = $buildable; | |||||
return $this; | |||||
} | |||||
public function getBuildable() { | |||||
return $this->assertAttached($this->buildable); | |||||
} | |||||
public function getName() { | |||||
if ($this->getBuildPlan()) { | |||||
return $this->getBuildPlan()->getName(); | |||||
} | |||||
return pht('Build'); | |||||
} | |||||
public function attachBuildPlan( | |||||
HarbormasterBuildPlan $build_plan = null) { | |||||
$this->buildPlan = $build_plan; | |||||
return $this; | |||||
} | |||||
public function getBuildPlan() { | |||||
return $this->assertAttached($this->buildPlan); | |||||
} | |||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | |||||
public function getCapabilities() { | |||||
return array( | |||||
PhabricatorPolicyCapability::CAN_VIEW, | |||||
); | |||||
} | |||||
public function getPolicy($capability) { | |||||
return $this->getBuildable()->getPolicy($capability); | |||||
} | |||||
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { | |||||
return $this->getBuildable()->hasAutomaticCapability( | |||||
$capability, | |||||
$viewer); | |||||
} | |||||
public function describeAutomaticCapability($capability) { | |||||
return pht( | |||||
'Users must be able to see a buildable to view its build plans.'); | |||||
} | |||||
} |