Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / herald / action / HeraldCommentAction.php
blobf8b8fbe8135cd930f696ffdd84de3e7ebc237e93
1 <?php
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)) {
18 return false;
21 $xaction = $object->getApplicationTransactionTemplate();
23 $comment = $xaction->getApplicationTransactionCommentObject();
24 if (!$comment) {
25 return false;
28 return true;
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() {
57 return array(
58 self::DO_COMMENT => array(
59 'icon' => 'fa-comment',
60 'color' => 'blue',
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);