Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / people / engine / PhabricatorPeopleProfileMenuEngine.php
blob6d6d239f5be9756925eebd7f060f8db6e5769885
1 <?php
3 final class PhabricatorPeopleProfileMenuEngine
4 extends PhabricatorProfileMenuEngine {
6 const ITEM_PROFILE = 'people.profile';
7 const ITEM_MANAGE = 'people.manage';
8 const ITEM_PICTURE = 'people.picture';
9 const ITEM_BADGES = 'people.badges';
10 const ITEM_TASKS = 'people.tasks';
11 const ITEM_COMMITS = 'people.commits';
12 const ITEM_REVISIONS = 'people.revisions';
14 protected function isMenuEngineConfigurable() {
15 return false;
18 public function getItemURI($path) {
19 $user = $this->getProfileObject();
20 $username = $user->getUsername();
21 $username = phutil_escape_uri($username);
22 return "/p/{$username}/item/{$path}";
25 protected function getBuiltinProfileItems($object) {
26 $viewer = $this->getViewer();
28 $items = array();
30 $items[] = $this->newItem()
31 ->setBuiltinKey(self::ITEM_PICTURE)
32 ->setMenuItemKey(PhabricatorPeoplePictureProfileMenuItem::MENUITEMKEY);
34 $items[] = $this->newItem()
35 ->setBuiltinKey(self::ITEM_PROFILE)
36 ->setMenuItemKey(PhabricatorPeopleDetailsProfileMenuItem::MENUITEMKEY);
38 $have_badges = PhabricatorApplication::isClassInstalledForViewer(
39 'PhabricatorBadgesApplication',
40 $viewer);
41 if ($have_badges) {
42 $items[] = $this->newItem()
43 ->setBuiltinKey(self::ITEM_BADGES)
44 ->setMenuItemKey(PhabricatorPeopleBadgesProfileMenuItem::MENUITEMKEY);
47 $have_maniphest = PhabricatorApplication::isClassInstalledForViewer(
48 'PhabricatorManiphestApplication',
49 $viewer);
50 if ($have_maniphest) {
51 $items[] = $this->newItem()
52 ->setBuiltinKey(self::ITEM_TASKS)
53 ->setMenuItemKey(PhabricatorPeopleTasksProfileMenuItem::MENUITEMKEY);
56 $have_differential = PhabricatorApplication::isClassInstalledForViewer(
57 'PhabricatorDifferentialApplication',
58 $viewer);
59 if ($have_differential) {
60 $items[] = $this->newItem()
61 ->setBuiltinKey(self::ITEM_REVISIONS)
62 ->setMenuItemKey(
63 PhabricatorPeopleRevisionsProfileMenuItem::MENUITEMKEY);
66 $have_diffusion = PhabricatorApplication::isClassInstalledForViewer(
67 'PhabricatorDiffusionApplication',
68 $viewer);
69 if ($have_diffusion) {
70 $items[] = $this->newItem()
71 ->setBuiltinKey(self::ITEM_COMMITS)
72 ->setMenuItemKey(PhabricatorPeopleCommitsProfileMenuItem::MENUITEMKEY);
75 $items[] = $this->newItem()
76 ->setBuiltinKey(self::ITEM_MANAGE)
77 ->setMenuItemKey(PhabricatorPeopleManageProfileMenuItem::MENUITEMKEY);
79 return $items;