@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 PhabricatorProjectSubprojectsProfileMenuItem
4 extends PhabricatorProfileMenuItem {
5
6 const MENUITEMKEY = 'project.subprojects';
7
8 public function getMenuItemTypeName() {
9 return pht('Project Subprojects');
10 }
11
12 private function getDefaultName() {
13 return pht('Subprojects');
14 }
15
16 public function getMenuItemTypeIcon() {
17 return 'fa-sitemap';
18 }
19
20 public function shouldEnableForObject($object) {
21 if ($object->isMilestone()) {
22 return false;
23 }
24
25 return true;
26 }
27
28 public function getDisplayName(
29 PhabricatorProfileMenuItemConfiguration $config) {
30 $name = $config->getMenuItemProperty('name');
31
32 if (phutil_nonempty_string($name)) {
33 return $name;
34 }
35
36 return $this->getDefaultName();
37 }
38
39 public function buildEditEngineFields(
40 PhabricatorProfileMenuItemConfiguration $config) {
41 return array(
42 id(new PhabricatorTextEditField())
43 ->setKey('name')
44 ->setLabel(pht('Name'))
45 ->setPlaceholder($this->getDefaultName())
46 ->setValue($config->getMenuItemProperty('name')),
47 );
48 }
49
50 protected function newMenuItemViewList(
51 PhabricatorProfileMenuItemConfiguration $config) {
52
53 $project = $config->getProfileObject();
54 $id = $project->getID();
55
56 $name = $this->getDisplayName($config);
57 $icon = 'fa-sitemap';
58 $uri = "/project/subprojects/{$id}/";
59
60 $item = $this->newItemView()
61 ->setURI($uri)
62 ->setName($name)
63 ->setIcon($icon);
64
65 return array(
66 $item,
67 );
68 }
69
70}