Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/storage/HarbormasterBuildable.php
| <?php | <?php | ||||
| final class HarbormasterBuildable extends HarbormasterDAO | final class HarbormasterBuildable extends HarbormasterDAO | ||||
| implements PhabricatorPolicyInterface { | implements | ||||
| PhabricatorPolicyInterface, | |||||
| HarbormasterBuildableInterface { | |||||
| protected $buildablePHID; | protected $buildablePHID; | ||||
| protected $containerPHID; | protected $containerPHID; | ||||
| protected $buildStatus; | protected $buildStatus; | ||||
| protected $buildableStatus; | protected $buildableStatus; | ||||
| protected $isManualBuildable; | protected $isManualBuildable; | ||||
| private $buildableObject = self::ATTACHABLE; | private $buildableObject = self::ATTACHABLE; | ||||
| ▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | $plans = id(new HarbormasterBuildPlanQuery()) | ||||
| ->execute(); | ->execute(); | ||||
| foreach ($plans as $plan) { | foreach ($plans as $plan) { | ||||
| if ($plan->isDisabled()) { | if ($plan->isDisabled()) { | ||||
| // TODO: This should be communicated more clearly -- maybe we should | // TODO: This should be communicated more clearly -- maybe we should | ||||
| // create the build but set the status to "disabled" or "derelict". | // create the build but set the status to "disabled" or "derelict". | ||||
| continue; | continue; | ||||
| } | } | ||||
| $build = HarbormasterBuild::initializeNewBuild( | $buildable->applyPlan($plan); | ||||
| PhabricatorUser::getOmnipotentUser()); | } | ||||
| $build->setBuildablePHID($buildable->getPHID()); | } | ||||
| $build->setBuildPlanPHID($plan->getPHID()); | |||||
| $build->setBuildStatus(HarbormasterBuild::STATUS_PENDING); | public function applyPlan(HarbormasterBuildPlan $plan) { | ||||
| $build->save(); | $viewer = PhabricatorUser::getOmnipotentUser(); | ||||
| $build = HarbormasterBuild::initializeNewBuild($viewer) | |||||
| ->setBuildablePHID($this->getPHID()) | |||||
| ->setBuildPlanPHID($plan->getPHID()) | |||||
| ->setBuildStatus(HarbormasterBuild::STATUS_PENDING) | |||||
| ->save(); | |||||
| PhabricatorWorker::scheduleTask( | PhabricatorWorker::scheduleTask( | ||||
| 'HarbormasterBuildWorker', | 'HarbormasterBuildWorker', | ||||
| array( | array( | ||||
| 'buildID' => $build->getID() | 'buildID' => $build->getID() | ||||
| )); | )); | ||||
| } | |||||
| return $this; | |||||
| } | } | ||||
| public function getConfiguration() { | public function getConfiguration() { | ||||
| return array( | return array( | ||||
| self::CONFIG_AUX_PHID => true, | self::CONFIG_AUX_PHID => true, | ||||
| ) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
| } | } | ||||
| public function describeAutomaticCapability($capability) { | public function describeAutomaticCapability($capability) { | ||||
| return pht( | return pht( | ||||
| 'Users must be able to see the revision or repository to see a '. | 'Users must be able to see the revision or repository to see a '. | ||||
| 'buildable.'); | 'buildable.'); | ||||
| } | } | ||||
| /* -( HarbormasterBuildableInterface )------------------------------------- */ | |||||
| public function getHarbormasterBuildablePHID() { | |||||
| // NOTE: This is essentially just for convenience, as it allows you create | |||||
| // a copy of a buildable by specifying `B123` without bothering to go | |||||
| // look up the underlying object. | |||||
| return $this->getBuildablePHID(); | |||||
| } | |||||
| public function getHarbormasterContainerPHID() { | |||||
| return $this->getContainerPHID(); | |||||
| } | |||||
| } | } | ||||