Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F82569191
DrydockManagementReleaseLeaseWorkflow.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
Thu, Sep 12, 04:27
Size
1 KB
Mime Type
text/x-php
Expires
Sat, Sep 14, 04:27 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20715034
Attached To
rPH Phabricator
DrydockManagementReleaseLeaseWorkflow.php
View Options
<?php
final
class
DrydockManagementReleaseLeaseWorkflow
extends
DrydockManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'release-lease'
)
->
setSynopsis
(
pht
(
'Release a lease.'
))
->
setArguments
(
array
(
array
(
'name'
=>
'id'
,
'param'
=>
'id'
,
'repeat'
=>
true
,
'help'
=>
pht
(
'Lease ID to release.'
),
),
));
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$ids
=
$args
->
getArg
(
'id'
);
if
(!
$ids
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Specify one or more lease IDs to release with "%s".'
,
'--id'
));
}
$viewer
=
$this
->
getViewer
();
$drydock_phid
=
id
(
new
PhabricatorDrydockApplication
())->
getPHID
();
$leases
=
id
(
new
DrydockLeaseQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
$ids
)
->
execute
();
PhabricatorWorker
::
setRunAllTasksInProcess
(
true
);
foreach
(
$ids
as
$id
)
{
$lease
=
idx
(
$leases
,
$id
);
if
(!
$lease
)
{
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Lease "%s" does not exist.'
,
$id
));
continue
;
}
if
(!
$lease
->
canRelease
())
{
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Lease "%s" is not releasable.'
,
$id
));
continue
;
}
$command
=
DrydockCommand
::
initializeNewCommand
(
$viewer
)
->
setTargetPHID
(
$lease
->
getPHID
())
->
setAuthorPHID
(
$drydock_phid
)
->
setCommand
(
DrydockCommand
::
COMMAND_RELEASE
)
->
save
();
$lease
->
scheduleUpdate
();
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Scheduled release of lease "%s".'
,
$id
));
}
}
}
Event Timeline
Log In to Comment