Add a basic "harbormaster.step.edit" API method
[phabricator/blender.git] / src / view / layout / PHUIApplicationMenuView.php
blob164f897550fc27aaf8c908eec02f45fecc21705c
1 <?php
3 final class PHUIApplicationMenuView extends Phobject {
5 private $viewer;
6 private $crumbs;
7 private $searchEngine;
8 private $profileMenu;
10 private $items = array();
12 public function setViewer(PhabricatorUser $viewer) {
13 $this->viewer = $viewer;
14 return $this;
17 public function getViewer() {
18 return $this->viewer;
21 public function addLabel($name) {
22 $item = id(new PHUIListItemView())
23 ->setName($name);
25 return $this->addItem($item);
28 public function addLink($name, $href) {
29 $item = id(new PHUIListItemView())
30 ->setName($name)
31 ->setHref($href);
33 return $this->addItem($item);
36 public function setProfileMenu(
37 AphrontSideNavFilterView $nav) {
38 $this->profileMenu = $nav;
39 return $this;
42 public function getProfileMenu() {
43 return $this->profileMenu;
46 public function addItem(PHUIListItemView $item) {
47 $this->items[] = $item;
48 return $this;
51 public function setSearchEngine(PhabricatorApplicationSearchEngine $engine) {
52 $this->searchEngine = $engine;
53 return $this;
56 public function getSearchEngine() {
57 return $this->searchEngine;
60 public function setCrumbs(PHUICrumbsView $crumbs) {
61 $this->crumbs = $crumbs;
62 return $this;
65 public function getCrumbs() {
66 return $this->crumbs;
69 public function buildListView() {
70 $viewer = $this->getViewer();
72 $view = id(new PHUIListView())
73 ->setUser($viewer);
75 $profile_menu = $this->getProfileMenu();
76 if ($profile_menu) {
77 foreach ($profile_menu->getMenu()->getItems() as $item) {
78 if ($item->getHideInApplicationMenu()) {
79 continue;
82 $item = clone $item;
83 $view->addMenuItem($item);
87 $crumbs = $this->getCrumbs();
88 if ($crumbs) {
89 $actions = $crumbs->getActions();
90 if ($actions) {
91 $view->newLabel(pht('Create'));
92 foreach ($crumbs->getActions() as $action) {
93 $view->addMenuItem($action);
98 $engine = $this->getSearchEngine();
99 if ($engine) {
100 $engine
101 ->setViewer($viewer)
102 ->addNavigationItems($view);
105 foreach ($this->items as $item) {
106 $view->addMenuItem($item);
109 return $view;