public function buildNav()
 {
     $user = $this->getRequest()->getUser();
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI('/'));
     $applications = id(new PhabricatorApplicationQuery())->setViewer($user)->withInstalled(true)->withUnlisted(false)->withLaunchable(true)->execute();
     $pinned = $user->loadPreferences()->getPinnedApplications($applications, $user);
     // Force "Applications" to appear at the bottom.
     $meta_app = 'PhabricatorApplicationsApplication';
     $pinned = array_fuse($pinned);
     unset($pinned[$meta_app]);
     $pinned[$meta_app] = $meta_app;
     $applications[$meta_app] = PhabricatorApplication::getByClass($meta_app);
     $tiles = array();
     $home_app = new PhabricatorHomeApplication();
     $tiles[] = id(new PhabricatorApplicationLaunchView())->setApplication($home_app)->setApplicationStatus($home_app->loadStatus($user))->addClass('phabricator-application-launch-phone-only')->setUser($user);
     foreach ($pinned as $pinned_application) {
         if (empty($applications[$pinned_application])) {
             continue;
         }
         $application = $applications[$pinned_application];
         $tile = id(new PhabricatorApplicationLaunchView())->setApplication($application)->setApplicationStatus($application->loadStatus($user))->setUser($user);
         $tiles[] = $tile;
     }
     $nav->addCustomBlock(phutil_tag('div', array('class' => 'application-tile-group'), $tiles));
     $nav->addFilter('', pht('Customize Applications...'), '/settings/panel/home/');
     $nav->addClass('phabricator-side-menu-home');
     $nav->selectFilter(null);
     return $nav;
 }
 private function newAutomaticMenuItems(AphrontSideNavFilterView $nav)
 {
     $items = array();
     // NOTE: We're adding a spacer item for the fixed footer, so that if the
     // menu taller than the page content you can still scroll down the page far
     // enough to access the last item without the content being obscured by the
     // fixed items.
     $items[] = id(new PHUIListItemView())->setHideInApplicationMenu(true)->addClass('phui-profile-menu-spacer');
     $collapse_id = celerity_generate_unique_node_id();
     $viewer = $this->getViewer();
     $collapse_key = PhabricatorUserPreferences::PREFERENCE_PROFILE_MENU_COLLAPSED;
     $preferences = $viewer->loadPreferences();
     $is_collapsed = $preferences->getPreference($collapse_key, false);
     if ($is_collapsed) {
         $nav->addClass('phui-profile-menu-collapsed');
     } else {
         $nav->addClass('phui-profile-menu-expanded');
     }
     if ($viewer->isLoggedIn()) {
         $settings_uri = '/settings/adjust/?key=' . $collapse_key;
     } else {
         $settings_uri = null;
     }
     Javelin::initBehavior('phui-profile-menu', array('menuID' => $nav->getMainID(), 'collapseID' => $collapse_id, 'isCollapsed' => (bool) $is_collapsed, 'settingsURI' => $settings_uri));
     $collapse_icon = id(new PHUIIconCircleView())->addClass('phui-list-item-icon')->addClass('phui-profile-menu-visible-when-expanded')->setIcon('fa-chevron-left');
     $expand_icon = id(new PHUIIconCircleView())->addClass('phui-list-item-icon')->addClass('phui-profile-menu-visible-when-collapsed')->addSigil('has-tooltip')->setMetadata(array('tip' => pht('Expand'), 'align' => 'E'))->setIcon('fa-chevron-right');
     $items[] = id(new PHUIListItemView())->setName('Collapse')->addIcon($collapse_icon)->addIcon($expand_icon)->setID($collapse_id)->addClass('phui-profile-menu-footer')->addClass('phui-profile-menu-footer-1')->setHideInApplicationMenu(true)->setHref('#');
     return $items;
 }