@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorCommentEditEngineExtension
4 extends PhabricatorEditEngineExtension {
5
6 const EXTENSIONKEY = 'transactions.comment';
7 const EDITKEY = 'comment';
8
9 public function getExtensionPriority() {
10 return 9000;
11 }
12
13 public function isExtensionEnabled() {
14 return true;
15 }
16
17 public function getExtensionName() {
18 return pht('Comments');
19 }
20
21 public function supportsObject(
22 PhabricatorEditEngine $engine,
23 PhabricatorApplicationTransactionInterface $object) {
24
25 $xaction = $object->getApplicationTransactionTemplate();
26 $comment = $xaction->getApplicationTransactionCommentObject();
27
28 return (bool)$comment;
29 }
30
31 public function newBulkEditGroups(PhabricatorEditEngine $engine) {
32 return array(
33 id(new PhabricatorBulkEditGroup())
34 ->setKey('comments')
35 ->setLabel(pht('Comments')),
36 );
37 }
38
39 public function buildCustomEditFields(
40 PhabricatorEditEngine $engine,
41 PhabricatorApplicationTransactionInterface $object) {
42
43 $comment_type = PhabricatorTransactions::TYPE_COMMENT;
44
45 // Comments have a lot of special behavior which doesn't always check
46 // this flag, but we set it for consistency.
47 $is_interact = true;
48
49 $comment_field = id(new PhabricatorCommentEditField())
50 ->setKey(self::EDITKEY)
51 ->setLabel(pht('Comments'))
52 ->setBulkEditLabel(pht('Add comment'))
53 ->setBulkEditGroupKey('comments')
54 ->setAliases(array('comments'))
55 ->setIsFormField(false)
56 ->setCanApplyWithoutEditCapability($is_interact)
57 ->setTransactionType($comment_type)
58 ->setConduitDescription(pht('Make comments.'))
59 ->setConduitTypeDescription(
60 pht('Comment to add, formatted as remarkup.'))
61 ->setValue(null);
62
63 return array(
64 $comment_field,
65 );
66 }
67
68}