Page MenuHomePhabricator

D13503.diff
No OneTemporary

D13503.diff

diff --git a/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
--- a/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
+++ b/src/applications/drydock/blueprint/DrydockBlueprintImplementation.php
@@ -10,6 +10,7 @@
private $activeResource;
private $activeLease;
private $instance;
+ private $scopes = array();
abstract public function getType();
abstract public function getInterface(
@@ -617,10 +618,11 @@
DrydockResource $resource = null,
DrydockLease $lease = null) {
- if (($this->activeResource !== null) ||
- ($this->activeLease !== null)) {
- throw new Exception(pht('There is already an active resource or lease!'));
- }
+ $scope = array(
+ 'resource' => $resource,
+ 'lease' => $lease,
+ );
+ array_push($this->scopes, $scope);
$this->activeResource = $resource;
$this->activeLease = $lease;
@@ -629,8 +631,20 @@
}
public function popActiveScope() {
- $this->activeResource = null;
- $this->activeLease = null;
+ if (count($this->scopes) === 0) {
+ throw new Exception('Unable to pop active scope; no scopes active');
+ }
+
+ array_pop($this->scopes);
+
+ if (count($this->scopes) === 0) {
+ $this->activeResource = null;
+ $this->activeLease = null;
+ } else {
+ $current = last($this->scopes);
+ $this->activeResource = $current['resource'];
+ $this->activeLease = $current['lease'];
+ }
}
}

File Metadata

Mime Type
text/plain
Expires
Wed, May 8, 10:50 PM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6273386
Default Alt Text
D13503.diff (1 KB)

Event Timeline