Changeset View
Changeset View
Standalone View
Standalone View
src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
Show All 13 Lines | abstract class DrydockBlueprintImplementation { | ||||
abstract public function getType(); | abstract public function getType(); | ||||
abstract public function getInterface( | abstract public function getInterface( | ||||
DrydockResource $resource, | DrydockResource $resource, | ||||
DrydockLease $lease, | DrydockLease $lease, | ||||
$type); | $type); | ||||
abstract public function isEnabled(); | abstract public function isEnabled(); | ||||
abstract public function getBlueprintName(); | |||||
abstract public function getDescription(); | abstract public function getDescription(); | ||||
public function getBlueprintClass() { | public function getBlueprintClass() { | ||||
return get_class($this); | return get_class($this); | ||||
} | } | ||||
protected function loadLease($lease_id) { | protected function loadLease($lease_id) { | ||||
// TODO: Get rid of this? | // TODO: Get rid of this? | ||||
▲ Show 20 Lines • Show All 353 Lines • ▼ Show 20 Lines | /* -( Logging )------------------------------------------------------------ */ | ||||
public static function getAllBlueprintImplementationsForResource($type) { | public static function getAllBlueprintImplementationsForResource($type) { | ||||
static $groups = null; | static $groups = null; | ||||
if ($groups === null) { | if ($groups === null) { | ||||
$groups = mgroup(self::getAllBlueprintImplementations(), 'getType'); | $groups = mgroup(self::getAllBlueprintImplementations(), 'getType'); | ||||
} | } | ||||
return idx($groups, $type, array()); | return idx($groups, $type, array()); | ||||
} | } | ||||
public static function getNamedImplementation($class) { | |||||
return idx(self::getAllBlueprintImplementations(), $class); | |||||
} | |||||
protected function newResourceTemplate($name) { | protected function newResourceTemplate($name) { | ||||
$resource = id(new DrydockResource()) | $resource = id(new DrydockResource()) | ||||
->setBlueprintPHID($this->getInstance()->getPHID()) | ->setBlueprintPHID($this->getInstance()->getPHID()) | ||||
->setBlueprintClass($this->getBlueprintClass()) | ->setBlueprintClass($this->getBlueprintClass()) | ||||
->setType($this->getType()) | ->setType($this->getType()) | ||||
->setStatus(DrydockResourceStatus::STATUS_PENDING) | ->setStatus(DrydockResourceStatus::STATUS_PENDING) | ||||
->setName($name) | ->setName($name) | ||||
->save(); | ->save(); | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |