3 final class HeraldCommentAction
extends HeraldAction
{
5 const ACTIONCONST
= 'comment';
6 const DO_COMMENT
= 'do.comment';
8 public function getHeraldActionName() {
9 return pht('Add comment');
12 public function getActionGroupKey() {
13 return HeraldUtilityActionGroup
::ACTIONGROUPKEY
;
16 public function supportsObject($object) {
17 if (!($object instanceof PhabricatorApplicationTransactionInterface
)) {
21 $xaction = $object->getApplicationTransactionTemplate();
23 $comment = $xaction->getApplicationTransactionCommentObject();
31 public function supportsRuleType($rule_type) {
32 return ($rule_type != HeraldRuleTypeConfig
::RULE_TYPE_PERSONAL
);
35 public function applyEffect($object, HeraldEffect
$effect) {
36 $adapter = $this->getAdapter();
37 $comment_text = $effect->getTarget();
39 $xaction = $adapter->newTransaction()
40 ->setTransactionType(PhabricatorTransactions
::TYPE_COMMENT
);
42 $comment = $xaction->getApplicationTransactionCommentObject()
43 ->setContent($comment_text);
45 $xaction->attachComment($comment);
47 $adapter->queueTransaction($xaction);
49 $this->logEffect(self
::DO_COMMENT
, $comment_text);
52 public function getHeraldActionStandardType() {
53 return self
::STANDARD_REMARKUP
;
56 protected function getActionEffectMap() {
58 self
::DO_COMMENT
=> array(
59 'icon' => 'fa-comment',
61 'name' => pht('Added Comment'),
66 public function renderActionDescription($value) {
67 $summary = PhabricatorMarkupEngine
::summarize($value);
68 return pht('Add comment: %s', $summary);
71 protected function renderActionEffectDescription($type, $data) {
72 $summary = PhabricatorMarkupEngine
::summarize($data);
73 return pht('Added a comment: %s', $summary);