Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P1187
RequireProjectListener.php
Active
Public
Actions
Authored by
epriestley
on Jun 26 2014, 10:52 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Flag For Later
Award Token
Tags
None
Referenced Files
F170689: RequireProjectListener.php
Jun 26 2014, 10:52 PM
2014-06-26 22:52:42 (UTC+0)
Subscribers
None
<?php
final
class
RequireProjectListener
extends
PhabricatorAutoEventListener
{
public
function
register
()
{
$this
->
listen
(
PhabricatorEventType
::
TYPE_MANIPHEST_DIDEDITTASK
);
}
public
function
handleEvent
(
PhutilEvent
$event
)
{
$is_new
=
$event
->
getValue
(
'new'
);
if
(!
$is_new
)
{
return
;
}
$task
=
$event
->
getValue
(
'task'
);
$projects
=
$task
->
getProjectPHIDs
();
if
(
$projects
)
{
return
;
}
$comment
=
pht
(
'Egad! I neglected to set any projects. I will claim this task for '
.
'myself and remedy my grevious error post-haste!'
);
$xactions
=
array
();
$xactions
[]
=
id
(
new
ManiphestTransaction
())
->
setTransactionType
(
ManiphestTransaction
::
TYPE_OWNER
)
->
setNewValue
(
$task
->
getAuthorPHID
());
$xactions
[]
=
id
(
new
ManiphestTransaction
())
->
setTransactionType
(
PhabricatorTransactions
::
TYPE_COMMENT
)
->
attachComment
(
id
(
new
ManiphestTransactionComment
())
->
setContent
(
$comment
));
$content_source
=
PhabricatorContentSource
::
newForSource
(
PhabricatorContentSource
::
SOURCE_FAX
,
array
());
id
(
new
ManiphestTransactionEditor
())
->
setActor
(
$event
->
getUser
())
->
setContentSource
(
$content_source
)
->
applyTransactions
(
$task
,
$xactions
);
}
}
Event Timeline
epriestley
edited the content of this paste.
(Show Details)
Jun 26 2014, 10:52 PM
2014-06-26 22:52:42 (UTC+0)
epriestley
changed the title of this paste from untitled to
RequireProjectListener.php
.
epriestley
updated the paste's language from
autodetect
to
autodetect
.
Log In to Comment