Basic structure for MenuItem on Home

Summary: Ref T11957, builds out `/home/menu/` as a basic structure for adding/editing the homepage menu.

Test Plan: visit `/home/menu/` and add items to global and personal. Not wired to anything.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T11957

Differential Revision: https://secure.phabricator.com/D17180
This commit is contained in:
Chad Little
2017-01-11 12:35:16 -08:00
parent 2941b34acb
commit dfee1352e9
7 changed files with 240 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
<?php
final class PhabricatorHomeProfileMenuEngine
extends PhabricatorProfileMenuEngine {
protected function isMenuEngineConfigurable() {
return true;
}
protected function getItemURI($path) {
$object = $this->getProfileObject();
$custom = $this->getCustomPHID();
if ($custom) {
return "/home/menu/personal/item/{$path}";
} else {
return "/home/menu/global/item/{$path}";
}
}
protected function getBuiltinProfileItems($object) {
$viewer = $this->getViewer();
$items = array();
$custom_phid = $this->getCustomPHID();
$applications = id(new PhabricatorApplicationQuery())
->setViewer($viewer)
->withInstalled(true)
->withUnlisted(false)
->withLaunchable(true)
->execute();
foreach ($applications as $application) {
if (!$application->isPinnedByDefault($viewer)) {
continue;
}
$properties = array(
'name' => $application->getName(),
'application' => $application->getPHID(),
);
$items[] = $this->newItem()
->setBuiltinKey($application->getPHID())
->setMenuItemKey(PhabricatorApplicationProfileMenuItem::MENUITEMKEY)
->setMenuItemProperties($properties);
}
// Single Manage Item, switches URI based on admin/user
$items[] = $this->newItem()
->setBuiltinKey(PhabricatorHomeConstants::ITEM_MANAGE)
->setMenuItemKey(
PhabricatorHomeManageProfileMenuItem::MENUITEMKEY);
return $items;
}
}