Path: blob/master/src/applications/herald/action/HeraldCommentAction.php
12256 views
<?php12final class HeraldCommentAction extends HeraldAction {34const ACTIONCONST = 'comment';5const DO_COMMENT = 'do.comment';67public function getHeraldActionName() {8return pht('Add comment');9}1011public function getActionGroupKey() {12return HeraldUtilityActionGroup::ACTIONGROUPKEY;13}1415public function supportsObject($object) {16if (!($object instanceof PhabricatorApplicationTransactionInterface)) {17return false;18}1920$xaction = $object->getApplicationTransactionTemplate();2122$comment = $xaction->getApplicationTransactionCommentObject();23if (!$comment) {24return false;25}2627return true;28}2930public function supportsRuleType($rule_type) {31return ($rule_type != HeraldRuleTypeConfig::RULE_TYPE_PERSONAL);32}3334public function applyEffect($object, HeraldEffect $effect) {35$adapter = $this->getAdapter();36$comment_text = $effect->getTarget();3738$xaction = $adapter->newTransaction()39->setTransactionType(PhabricatorTransactions::TYPE_COMMENT);4041$comment = $xaction->getApplicationTransactionCommentObject()42->setContent($comment_text);4344$xaction->attachComment($comment);4546$adapter->queueTransaction($xaction);4748$this->logEffect(self::DO_COMMENT, $comment_text);49}5051public function getHeraldActionStandardType() {52return self::STANDARD_REMARKUP;53}5455protected function getActionEffectMap() {56return array(57self::DO_COMMENT => array(58'icon' => 'fa-comment',59'color' => 'blue',60'name' => pht('Added Comment'),61),62);63}6465public function renderActionDescription($value) {66$summary = PhabricatorMarkupEngine::summarize($value);67return pht('Add comment: %s', $summary);68}6970protected function renderActionEffectDescription($type, $data) {71$summary = PhabricatorMarkupEngine::summarize($data);72return pht('Added a comment: %s', $summary);73}7475}767778