@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 PhabricatorCustomFieldEditEngineExtension
4 extends PhabricatorEditEngineExtension {
5
6 const EXTENSIONKEY = 'customfield.fields';
7
8 public function getExtensionPriority() {
9 return 5000;
10 }
11
12 public function isExtensionEnabled() {
13 return true;
14 }
15
16 public function getExtensionName() {
17 return pht('Custom Fields');
18 }
19
20 public function supportsObject(
21 PhabricatorEditEngine $engine,
22 PhabricatorApplicationTransactionInterface $object) {
23 return ($object instanceof PhabricatorCustomFieldInterface);
24 }
25
26 public function newBulkEditGroups(PhabricatorEditEngine $engine) {
27 return array(
28 id(new PhabricatorBulkEditGroup())
29 ->setKey('custom')
30 ->setLabel(pht('Custom Fields')),
31 );
32 }
33
34 public function buildCustomEditFields(
35 PhabricatorEditEngine $engine,
36 PhabricatorApplicationTransactionInterface $object) {
37
38 $viewer = $this->getViewer();
39
40 $field_list = PhabricatorCustomField::getObjectFields(
41 $object,
42 PhabricatorCustomField::ROLE_EDITENGINE);
43
44 $field_list->setViewer($viewer);
45
46 if ($object->getID()) {
47 $field_list->readFieldsFromStorage($object);
48 }
49
50 $results = array();
51 foreach ($field_list->getFields() as $field) {
52 $edit_fields = $field->getEditEngineFields($engine);
53 foreach ($edit_fields as $edit_field) {
54 $group_key = $edit_field->getBulkEditGroupKey();
55 if ($group_key === null) {
56 $edit_field->setBulkEditGroupKey('custom');
57 }
58
59 $results[] = $edit_field;
60 }
61 }
62
63 return $results;
64 }
65
66}