Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P1895
AddCommentHeraldAction.php
Active
Public
Actions
Authored by
epriestley
on Nov 25 2015, 8:59 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
Herald
Referenced Files
F1003226: AddCommentHeraldAction.php
Nov 25 2015, 8:59 PM
2015-11-25 20:59:47 (UTC+0)
Subscribers
kaw
Luke081515.2
Tokens
"Like" token, awarded by kaw.
"Piece of Eight" token, awarded by chad.
<?php
final
class
AddCommentHeraldAction
extends
HeraldAction
{
const
ACTIONCONST
=
'custom.transactions.comment'
;
const
DO_COMMENT
=
'do.comment'
;
public
function
getHeraldActionName
()
{
return
pht
(
'Add comment'
);
}
public
function
getActionGroupKey
()
{
return
HeraldUtilityActionGroup
::
ACTIONGROUPKEY
;
}
public
function
supportsObject
(
$object
)
{
if
(!(
$object
instanceof
PhabricatorApplicationTransactionInterface
))
{
return
false
;
}
$xaction
=
$object
->
getApplicationTransactionTemplate
();
try
{
$comment
=
$xaction
->
getApplicationTransactionCommentObject
();
if
(!
$comment
)
{
return
false
;
}
}
catch
(
Exception
$ex
)
{
return
false
;
}
return
true
;
}
public
function
supportsRuleType
(
$rule_type
)
{
return
true
;
}
public
function
applyEffect
(
$object
,
HeraldEffect
$effect
)
{
$adapter
=
$this
->
getAdapter
();
$comment_text
=
$effect
->
getTarget
();
$comment
=
$adapter
->
newTransaction
()
->
getApplicationTransactionCommentObject
()
->
setContent
(
$comment_text
);
$xaction
=
$adapter
->
newTransaction
()
->
setTransactionType
(
PhabricatorTransactions
::
TYPE_COMMENT
)
->
attachComment
(
$comment
);
$adapter
->
queueTransaction
(
$xaction
);
$this
->
logEffect
(
self
::
DO_COMMENT
);
}
public
function
getHeraldActionStandardType
()
{
return
self
::
STANDARD_TEXT
;
}
public
function
renderActionDescription
(
$value
)
{
return
pht
(
'Add comment: %s'
,
$value
);
}
protected
function
getActionEffectMap
()
{
return
array
(
self
::
DO_COMMENT
=>
array
(
'icon'
=>
'fa-comment'
,
'color'
=>
'blue'
,
'name'
=>
pht
(
'Added comment.'
),
),
);
}
protected
function
renderActionEffectDescription
(
$type
,
$data
)
{
switch
(
$type
)
{
case
self
::
DO_COMMENT
:
return
pht
(
'Added comment.'
);
}
}
}
Event Timeline
epriestley
changed the title of this paste from untitled to
AddCommentHeraldAction.php
.
Nov 25 2015, 8:59 PM
2015-11-25 20:59:47 (UTC+0)
epriestley
edited the content of this paste.
(Show Details)
chad
awarded a token.
Nov 25 2015, 9:01 PM
2015-11-25 21:01:01 (UTC+0)
epriestley
mentioned this in
T9853: Support comments in Herald Actions
.
Nov 25 2015, 9:02 PM
2015-11-25 21:02:16 (UTC+0)
epriestley
mentioned this in
T8682: Commit hooks should have better notification options for committers
.
Dec 9 2015, 1:32 PM
2015-12-09 13:32:16 (UTC+0)
kaw
added a subscriber:
kaw
.
Jan 20 2016, 1:33 PM
2016-01-20 13:33:11 (UTC+0)
kaw
mentioned this in
T10183: Allow Herald to add a comment to a Maniphest task
.
Jan 21 2016, 8:43 AM
2016-01-21 08:43:32 (UTC+0)
Luke081515.2
added a project:
Herald
.
Jan 21 2016, 6:28 PM
2016-01-21 18:28:51 (UTC+0)
Luke081515.2
added a subscriber:
Luke081515.2
.
kaw
awarded a token.
Jan 22 2016, 9:56 AM
2016-01-22 09:56:53 (UTC+0)
epriestley
mentioned this in
D18823: Allow Herald rules to add comments
.
Dec 11 2017, 7:49 PM
2017-12-11 19:49:34 (UTC+0)
epriestley
mentioned this in
rPc9a0d68340ba: Allow Herald rules to add comments
.
Dec 18 2017, 5:11 PM
2017-12-18 17:11:07 (UTC+0)
Log In to Comment