Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F70228614
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 5, 20:45
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Jul 7, 20:45 (2 d)
Engine
blob
Format
Raw Data
Handle
18809517
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