Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96133767
DrydockManagementReleaseWorkflow.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Dec 23, 00:06
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 00:06 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23129776
Attached To
rPH Phabricator
DrydockManagementReleaseWorkflow.php
View Options
<?php
final
class
DrydockManagementReleaseWorkflow
extends
DrydockManagementWorkflow
{
public
function
didConstruct
()
{
$this
->
setName
(
'release'
)
->
setSynopsis
(
'Release a lease.'
)
->
setArguments
(
array
(
array
(
'name'
=>
'ids'
,
'wildcard'
=>
true
,
),
));
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$console
=
PhutilConsole
::
getConsole
();
$ids
=
$args
->
getArg
(
'ids'
);
if
(!
$ids
)
{
throw
new
PhutilArgumentUsageException
(
"Specify one or more lease IDs to release."
);
}
$viewer
=
$this
->
getViewer
();
$leases
=
id
(
new
DrydockLeaseQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
$ids
)
->
execute
();
foreach
(
$ids
as
$id
)
{
$lease
=
idx
(
$leases
,
$id
);
if
(!
$lease
)
{
$console
->
writeErr
(
"Lease %d does not exist!
\n
"
,
$id
);
}
else
if
(
$lease
->
getStatus
()
!=
DrydockLeaseStatus
::
STATUS_ACTIVE
)
{
$console
->
writeErr
(
"Lease %d is not 'active'!
\n
"
,
$id
);
}
else
{
$resource
=
$lease
->
getResource
();
$blueprint
=
$resource
->
getBlueprint
();
$blueprint
->
releaseLease
(
$resource
,
$lease
);
$console
->
writeErr
(
"Released lease %d.
\n
"
,
$id
);
}
}
}
}
Event Timeline
Log In to Comment