Files
phabricator/src/applications/project/controller/PhabricatorProjectViewController.php
epriestley 408cbd633c On portals, make the "selected" / "default" logic more straightforward
Summary:
Depends on D20349. Ref T13275. Currently, a default item is selected as a side effect of generating the full list of items, for absolutely no reason.

The logic to pick the currently selected item can also be separated out pretty easily.

(And fix a bug in with a weird edge case in projects.)

This doesn't really change anything, but it will probably make T12949 a bit easier to fix.

Test Plan: Viewed Home / projects / portals, clicked various links, got same default/selection behavior as before.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13275

Differential Revision: https://secure.phabricator.com/D20352
2019-04-02 14:44:26 -07:00

49 lines
1.3 KiB
PHP

<?php
final class PhabricatorProjectViewController
extends PhabricatorProjectController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$request = $this->getRequest();
$viewer = $request->getViewer();
$response = $this->loadProject();
if ($response) {
return $response;
}
$project = $this->getProject();
$engine = $this->getProfileMenuEngine();
$default = $engine->getDefaultItem();
// If defaults are broken somehow, serve the manage page. See T13033 for
// discussion.
if ($default) {
$default_key = $default->getBuiltinKey();
} else {
$default_key = PhabricatorProject::ITEM_MANAGE;
}
switch ($default_key) {
case PhabricatorProject::ITEM_WORKBOARD:
$controller_object = new PhabricatorProjectBoardViewController();
break;
case PhabricatorProject::ITEM_PROFILE:
$controller_object = new PhabricatorProjectProfileController();
break;
case PhabricatorProject::ITEM_MANAGE:
$controller_object = new PhabricatorProjectManageController();
break;
default:
return $engine->buildResponse();
}
return $this->delegateToController($controller_object);
}
}