From b070ed50197fe8370e4d207aa2d677a934283095 Mon Sep 17 00:00:00 2001 From: Chad Little Date: Mon, 23 Feb 2015 11:27:19 -0800 Subject: [PATCH] Make Project Mobile menu more resilient Summary: This sets $project at the controller level so it's available to building the icon nav and mobile menu, instead of guessing the $id. Fixes T7289 Test Plan: Test a project and its mobile menu when it does and does not have a workboard initialized. Also tested coming in via a slug and an id. Reviewers: epriestley, btrahan Reviewed By: btrahan Subscribers: Korvin, epriestley Maniphest Tasks: T7289 Differential Revision: https://secure.phabricator.com/D11848 --- .../PhabricatorProjectBoardController.php | 10 --------- .../PhabricatorProjectController.php | 21 +++++++++++++++---- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/applications/project/controller/PhabricatorProjectBoardController.php b/src/applications/project/controller/PhabricatorProjectBoardController.php index ef2e09f8f1..0837f9f5b7 100644 --- a/src/applications/project/controller/PhabricatorProjectBoardController.php +++ b/src/applications/project/controller/PhabricatorProjectBoardController.php @@ -3,16 +3,6 @@ abstract class PhabricatorProjectBoardController extends PhabricatorProjectController { - private $project; - - protected function setProject(PhabricatorProject $project) { - $this->project = $project; - return $this; - } - protected function getProject() { - return $this->project; - } - public function buildIconNavView(PhabricatorProject $project) { $id = $project->getID(); $nav = parent::buildIconNavView($project); diff --git a/src/applications/project/controller/PhabricatorProjectController.php b/src/applications/project/controller/PhabricatorProjectController.php index 4955f7fe3f..6b9b40d475 100644 --- a/src/applications/project/controller/PhabricatorProjectController.php +++ b/src/applications/project/controller/PhabricatorProjectController.php @@ -2,20 +2,32 @@ abstract class PhabricatorProjectController extends PhabricatorController { + private $project; + + protected function setProject(PhabricatorProject $project) { + $this->project = $project; + return $this; + } + + protected function getProject() { + return $this->project; + } + public function buildApplicationMenu() { return $this->buildSideNavView(true)->getMenu(); } public function buildSideNavView($for_app = false) { - $viewer = $this->getViewer(); + $project = $this->getProject(); $nav = new AphrontSideNavFilterView(); $nav->setBaseURI(new PhutilURI($this->getApplicationURI())); - $id = null; + $viewer = $this->getViewer(); + if ($for_app) { - $id = $this->getRequest()->getURIData('id'); - if ($id) { + if ($project) { + $id = $project->getID(); $nav->addFilter("profile/{$id}/", pht('Profile')); $nav->addFilter("board/{$id}/", pht('Workboard')); $nav->addFilter("members/{$id}/", pht('Members')); @@ -37,6 +49,7 @@ abstract class PhabricatorProjectController extends PhabricatorController { } public function buildIconNavView(PhabricatorProject $project) { + $this->setProject($project); $viewer = $this->getViewer(); $id = $project->getID(); $picture = $project->getProfileImageURI();