Store the "current" application in the controller
Summary: When we match an application route, select it as the current application and store it on the controller. Move routes for the major applications into their PhabricatorApplication classes so this works properly. Test Plan: Added a var_dump() and made sure we picked the right app for all these applications. Reviewers: vrana, btrahan Reviewed By: vrana CC: aran Maniphest Tasks: T1569 Differential Revision: https://secure.phabricator.com/D3144
This commit is contained in:
@@ -51,11 +51,31 @@ abstract class AphrontApplicationConfiguration {
|
||||
}
|
||||
|
||||
final public function buildController() {
|
||||
$map = $this->getURIMap();
|
||||
$mapper = new AphrontURIMapper($map);
|
||||
$request = $this->getRequest();
|
||||
$path = $request->getPath();
|
||||
list($controller_class, $uri_data) = $mapper->mapPath($path);
|
||||
|
||||
$maps = array();
|
||||
$maps[] = array(null, $this->getURIMap());
|
||||
|
||||
$applications = PhabricatorApplication::getAllInstalledApplications();
|
||||
foreach ($applications as $application) {
|
||||
$maps[] = array($application, $application->getRoutes());
|
||||
}
|
||||
|
||||
$current_application = null;
|
||||
foreach ($maps as $map_info) {
|
||||
list($application, $map) = $map_info;
|
||||
|
||||
$mapper = new AphrontURIMapper($map);
|
||||
list($controller_class, $uri_data) = $mapper->mapPath($path);
|
||||
|
||||
if ($controller_class) {
|
||||
if ($application) {
|
||||
$current_application = $application;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$controller_class) {
|
||||
if (!preg_match('@/$@', $path)) {
|
||||
@@ -75,6 +95,9 @@ abstract class AphrontApplicationConfiguration {
|
||||
}
|
||||
|
||||
$controller = newv($controller_class, array($request));
|
||||
if ($current_application) {
|
||||
$controller->setCurrentApplication($current_application);
|
||||
}
|
||||
|
||||
return array($controller, $uri_data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user