Differential D13984 Diff 33743 src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
| Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | public function getInstance() { | ||||
| return $this->instance; | return $this->instance; | ||||
| } | } | ||||
| public function attachInstance(DrydockBlueprint $instance) { | public function attachInstance(DrydockBlueprint $instance) { | ||||
| $this->instance = $instance; | $this->instance = $instance; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function supportsAutomaticCustomAttributes() { | |||||
| return true; | |||||
| } | |||||
| public function getFieldSpecifications() { | public function getFieldSpecifications() { | ||||
| if ($this->supportsAutomaticCustomAttributes()) { | |||||
| return array( | |||||
| 'attr-header' => array( | |||||
| 'name' => pht('Custom Attributes'), | |||||
| 'type' => 'header', | |||||
| ), | |||||
| 'attributes' => array( | |||||
| 'name' => pht('Attributes'), | |||||
| 'type' => 'textarea', | |||||
| 'caption' => pht( | |||||
| 'A newline separated list of custom blueprint '. | |||||
| 'attributes. Each attribute should be specified in '. | |||||
| 'a key=value format.'), | |||||
| 'monospace' => true, | |||||
| ), | |||||
| ); | |||||
| } else { | |||||
| return array(); | return array(); | ||||
| } | } | ||||
| } | |||||
| public function getDetail($key, $default = null) { | public function getDetail($key, $default = null) { | ||||
| return $this->getInstance()->getDetail($key, $default); | return $this->getInstance()->getDetail($key, $default); | ||||
| } | } | ||||
| /* -( Lease Acquisition )-------------------------------------------------- */ | /* -( Lease Acquisition )-------------------------------------------------- */ | ||||
| /** | /** | ||||
| * @task lease | * @task lease | ||||
| */ | */ | ||||
| final public function filterResource( | final public function filterResource( | ||||
| DrydockResource $resource, | DrydockResource $resource, | ||||
| DrydockLease $lease) { | DrydockLease $lease) { | ||||
| $scope = $this->pushActiveScope($resource, $lease); | $scope = $this->pushActiveScope($resource, $lease); | ||||
| if ($this->supportsAutomaticCustomAttributes()) { | |||||
| $custom_match = DrydockCustomAttributes::hasRequirements( | |||||
| $lease->getAttributes(), | |||||
| $this->getDetail('attributes', '')); | |||||
| if (!$custom_match) { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| return $this->canAllocateLease($resource, $lease); | return $this->canAllocateLease($resource, $lease); | ||||
| } | } | ||||
| /** | /** | ||||
| * Enforce basic checks on lease/resource compatibility. Allows resources to | * Enforce basic checks on lease/resource compatibility. Allows resources to | ||||
| * reject leases if they are incompatible, even if the resource types match. | * reject leases if they are incompatible, even if the resource types match. | ||||
| * | * | ||||
| ▲ Show 20 Lines • Show All 484 Lines • Show Last 20 Lines | |||||