@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 PhorgeFlagFlaggedObjectCustomField extends PhabricatorCustomField {
4
5 private $flag;
6
7 public function getFieldKey() {
8 return 'flag:flag';
9 }
10 public function shouldAppearInPropertyView() {
11 return false;
12 }
13
14 public function shouldAppearInListView() {
15 return true;
16 }
17
18 public function renderOnListItem(PHUIObjectItemView $view) {
19 if (!$this->flag) {
20 return;
21 }
22 // I'm very open to improvements in the way a Flag is displayed
23 $icon = PhabricatorFlagColor::getIcon($this->flag->getColor());
24 $view->addIcon($icon);
25 }
26
27
28 public function shouldUseStorage() {
29 return true;
30 }
31
32 public function setValueFromStorage($value) {
33 $this->flag = $value;
34 return $this;
35 }
36
37 // The parent function is defined to return a PhabricatorCustomFieldStorage,
38 // but that assumes a DTO with a particular form; That doesn't apply here.
39 // Maybe the function needs to be re-defined with a suitable interface.
40 // For now, PhorgeFlagFlaggedObjectFieldStorage just duck-types into the
41 // right shape.
42 public function newStorageObject() {
43 return id(new PhorgeFlagFlaggedObjectFieldStorage())
44 ->setViewer($this->getViewer());
45 }
46
47}