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