Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F71749961
PhabricatorWorkerManagementCancelWorkflow.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, Jul 12, 22:26
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Jul 14, 22:26 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
18983985
Attached To
rPH Phabricator
PhabricatorWorkerManagementCancelWorkflow.php
View Options
<?php
final
class
PhabricatorWorkerManagementCancelWorkflow
extends
PhabricatorWorkerManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'cancel'
)
->
setExamples
(
'**cancel** --id __id__'
)
->
setSynopsis
(
pht
(
'Cancel selected tasks. The work these tasks represent will never '
.
'be performed.'
))
->
setArguments
(
$this
->
getTaskSelectionArguments
());
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$console
=
PhutilConsole
::
getConsole
();
$tasks
=
$this
->
loadTasks
(
$args
);
foreach
(
$tasks
as
$task
)
{
$can_cancel
=
!
$task
->
isArchived
();
if
(!
$can_cancel
)
{
$console
->
writeOut
(
"**<bg:yellow> %s </bg>** %s
\n
"
,
pht
(
'ARCHIVED'
),
pht
(
'%s is already archived, and can not be cancelled.'
,
$this
->
describeTask
(
$task
)));
continue
;
}
// Forcibly break the lease if one exists, so we can archive the
// task.
$task
->
setLeaseOwner
(
null
);
$task
->
setLeaseExpires
(
PhabricatorTime
::
getNow
());
$task
->
archiveTask
(
PhabricatorWorkerArchiveTask
::
RESULT_CANCELLED
,
0
);
$console
->
writeOut
(
"**<bg:green> %s </bg>** %s
\n
"
,
pht
(
'CANCELLED'
),
pht
(
'%s was cancelled.'
,
$this
->
describeTask
(
$task
)));
}
return
0
;
}
}
Event Timeline
Log In to Comment