Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / auth / extension / PhabricatorAuthMainMenuBarExtension.php
blob042a6816dd9cb8da3375e6cee9b12ce504bbaef3
1 <?php
3 final class PhabricatorAuthMainMenuBarExtension
4 extends PhabricatorMainMenuBarExtension {
6 const MAINMENUBARKEY = 'auth';
8 public function isExtensionEnabledForViewer(PhabricatorUser $viewer) {
9 return true;
12 public function shouldRequireFullSession() {
13 return false;
16 public function getExtensionOrder() {
17 return 900;
20 public function buildMainMenus() {
21 $viewer = $this->getViewer();
23 if ($viewer->isLoggedIn()) {
24 return array();
27 $controller = $this->getController();
28 if ($controller instanceof PhabricatorAuthController) {
29 // Don't show the "Login" item on auth controllers, since they're
30 // generally all related to logging in anyway.
31 return array();
34 return array(
35 $this->buildLoginMenu(),
39 private function buildLoginMenu() {
40 $controller = $this->getController();
42 // See T13636. This button may be rendered by the 404 controller on sites
43 // other than the primary PlatformSite. Link the button to the primary
44 // site.
46 $uri = '/auth/start/';
47 $uri = PhabricatorEnv::getURI($uri);
48 $uri = new PhutilURI($uri);
49 if ($controller) {
50 $path = $controller->getRequest()->getPath();
51 $uri->replaceQueryParam('next', $path);
54 return id(new PHUIButtonView())
55 ->setTag('a')
56 ->setText(pht('Log In'))
57 ->setHref($uri)
58 ->setNoCSS(true)
59 ->addClass('phabricator-core-login-button');