Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101275867
DrydockManagementCloseWorkflow.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
Fri, Feb 7, 10:01
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Feb 9, 10:01 (2 d)
Engine
blob
Format
Raw Data
Handle
24126069
Attached To
rPH Phabricator
DrydockManagementCloseWorkflow.php
View Options
<?php
final
class
DrydockManagementCloseWorkflow
extends
DrydockManagementWorkflow
{
public
function
didConstruct
()
{
$this
->
setName
(
'close'
)
->
setSynopsis
(
'Close a resource.'
)
->
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 resource IDs to close.'
);
}
$viewer
=
$this
->
getViewer
();
$resources
=
id
(
new
DrydockResourceQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
$ids
)
->
execute
();
foreach
(
$ids
as
$id
)
{
$resource
=
idx
(
$resources
,
$id
);
if
(!
$resource
)
{
$console
->
writeErr
(
"Resource %d does not exist!
\n
"
,
$id
);
}
else
if
(
$resource
->
getStatus
()
!=
DrydockResourceStatus
::
STATUS_OPEN
)
{
$console
->
writeErr
(
"Resource %d is not 'open'!
\n
"
,
$id
);
}
else
{
$resource
->
closeResource
();
$console
->
writeErr
(
"Closed resource %d.
\n
"
,
$id
);
}
}
}
}
Event Timeline
Log In to Comment