Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F170689
RequireProjectListener.php
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
epriestley
Jun 26 2014, 10:52 PM
2014-06-26 22:52:42 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
RequireProjectListener.php
View Options
<?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
);
}
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/rp/pz/i2cdscrdmn2ajhb7
Default Alt Text
RequireProjectListener.php (1 KB)
Attached To
Mode
P1187 RequireProjectListener.php
Attached
Detach File
Event Timeline
Log In to Comment