@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+187 -138
+14 -1
src/aphront/AphrontController.php
··· 1 1 <?php 2 2 3 3 /* 4 - * Copyright 2011 Facebook, Inc. 4 + * Copyright 2012 Facebook, Inc. 5 5 * 6 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 7 * you may not use this file except in compliance with the License. ··· 22 22 abstract class AphrontController { 23 23 24 24 private $request; 25 + private $currentApplication; 25 26 26 27 public function willBeginExecution() { 27 28 return; ··· 43 44 44 45 final public function delegateToController(AphrontController $controller) { 45 46 return $controller->processRequest(); 47 + } 48 + 49 + 50 + final public function setCurrentApplication( 51 + PhabricatorApplication $current_application) { 52 + 53 + $this->currentApplication = $current_application; 54 + return $this; 55 + } 56 + 57 + final public function getCurrentApplication() { 58 + return $this->currentApplication; 46 59 } 47 60 48 61 }
+26 -3
src/aphront/configuration/AphrontApplicationConfiguration.php
··· 51 51 } 52 52 53 53 final public function buildController() { 54 - $map = $this->getURIMap(); 55 - $mapper = new AphrontURIMapper($map); 56 54 $request = $this->getRequest(); 57 55 $path = $request->getPath(); 58 - list($controller_class, $uri_data) = $mapper->mapPath($path); 56 + 57 + $maps = array(); 58 + $maps[] = array(null, $this->getURIMap()); 59 + 60 + $applications = PhabricatorApplication::getAllInstalledApplications(); 61 + foreach ($applications as $application) { 62 + $maps[] = array($application, $application->getRoutes()); 63 + } 64 + 65 + $current_application = null; 66 + foreach ($maps as $map_info) { 67 + list($application, $map) = $map_info; 68 + 69 + $mapper = new AphrontURIMapper($map); 70 + list($controller_class, $uri_data) = $mapper->mapPath($path); 71 + 72 + if ($controller_class) { 73 + if ($application) { 74 + $current_application = $application; 75 + } 76 + break; 77 + } 78 + } 59 79 60 80 if (!$controller_class) { 61 81 if (!preg_match('@/$@', $path)) { ··· 75 95 } 76 96 77 97 $controller = newv($controller_class, array($request)); 98 + if ($current_application) { 99 + $controller->setCurrentApplication($current_application); 100 + } 78 101 79 102 return array($controller, $uri_data); 80 103 }
+1 -133
src/aphront/configuration/AphrontDefaultApplicationConfiguration.php
··· 85 85 ), 86 86 '/api/(?P<method>[^/]+)' => 'PhabricatorConduitAPIController', 87 87 88 - '/D(?P<id>\d+)' => 'DifferentialRevisionViewController', 89 - '/differential/' => array( 90 - '' => 'DifferentialRevisionListController', 91 - 'filter/(?P<filter>\w+)/(?:(?P<username>\w+)/)?' => 92 - 'DifferentialRevisionListController', 93 - 'stats/(?P<filter>\w+)/' => 'DifferentialRevisionStatsController', 94 - 'diff/' => array( 95 - '(?P<id>\d+)/' => 'DifferentialDiffViewController', 96 - 'create/' => 'DifferentialDiffCreateController', 97 - ), 98 - 'changeset/' => 'DifferentialChangesetViewController', 99 - 'revision/edit/(?:(?P<id>\d+)/)?' 100 - => 'DifferentialRevisionEditController', 101 - 'comment/' => array( 102 - 'preview/(?P<id>\d+)/' => 'DifferentialCommentPreviewController', 103 - 'save/' => 'DifferentialCommentSaveController', 104 - 'inline/' => array( 105 - 'preview/(?P<id>\d+)/' => 106 - 'DifferentialInlineCommentPreviewController', 107 - 'edit/(?P<id>\d+)/' => 'DifferentialInlineCommentEditController', 108 - ), 109 - ), 110 - 'subscribe/(?P<action>add|rem)/(?P<id>\d+)/' 111 - => 'DifferentialSubscribeController', 112 - ), 113 - 114 88 '/typeahead/' => array( 115 89 'common/(?P<type>\w+)/' 116 90 => 'PhabricatorTypeaheadCommonDatasourceController', ··· 182 156 '(?:page/(?P<page>[^/]+)/)?' => 'PhabricatorUserSettingsController', 183 157 ), 184 158 185 - '/maniphest/' => array( 186 - '' => 'ManiphestTaskListController', 187 - 'view/(?P<view>\w+)/' => 'ManiphestTaskListController', 188 - 'report/(?:(?P<view>\w+)/)?' => 'ManiphestReportController', 189 - 'batch/' => 'ManiphestBatchEditController', 190 - 'task/' => array( 191 - 'create/' => 'ManiphestTaskEditController', 192 - 'edit/(?P<id>\d+)/' => 'ManiphestTaskEditController', 193 - 'descriptionchange/(?:(?P<id>\d+)/)?' => 194 - 'ManiphestTaskDescriptionChangeController', 195 - 'descriptionpreview/' => 196 - 'ManiphestTaskDescriptionPreviewController', 197 - ), 198 - 'transaction/' => array( 199 - 'save/' => 'ManiphestTransactionSaveController', 200 - 'preview/(?P<id>\d+)/' => 'ManiphestTransactionPreviewController', 201 - ), 202 - 'export/(?P<key>[^/]+)/' => 'ManiphestExportController', 203 - 'subpriority/' => 'ManiphestSubpriorityController', 204 - 'custom/' => array( 205 - '' => 'ManiphestSavedQueryListController', 206 - 'edit/(?:(?P<id>\d+)/)?' => 'ManiphestSavedQueryEditController', 207 - 'delete/(?P<id>\d+)/' => 'ManiphestSavedQueryDeleteController', 208 - ), 209 - ), 210 - 211 - '/T(?P<id>\d+)' => 'ManiphestTaskDetailController', 212 - 213 159 '/repository/' => array( 214 160 '' => 'PhabricatorRepositoryListController', 215 161 'create/' => 'PhabricatorRepositoryCreateController', ··· 241 187 => 'PhabricatorProjectUpdateController', 242 188 ), 243 189 244 - '/r(?P<callsign>[A-Z]+)(?P<commit>[a-z0-9]+)' 245 - => 'DiffusionCommitController', 246 - '/diffusion/' => array( 247 - '' => 'DiffusionHomeController', 248 - '(?P<callsign>[A-Z]+)/' => array( 249 - '' => 'DiffusionRepositoryController', 250 - 251 - 'repository/(?P<dblob>.*)' => 'DiffusionRepositoryController', 252 - 'change/(?P<dblob>.*)' => 'DiffusionChangeController', 253 - 'history/(?P<dblob>.*)' => 'DiffusionHistoryController', 254 - 'browse/(?P<dblob>.*)' => 'DiffusionBrowseController', 255 - 'lastmodified/(?P<dblob>.*)' => 'DiffusionLastModifiedController', 256 - 'diff/' => 'DiffusionDiffController', 257 - 'tags/(?P<dblob>.*)' => 'DiffusionTagListController', 258 - 'branches/(?P<dblob>.*)' => 'DiffusionBranchTableController', 259 - 260 - 'commit/(?P<commit>[a-z0-9]+)/branches/' 261 - => 'DiffusionCommitBranchesController', 262 - 'commit/(?P<commit>[a-z0-9]+)/tags/' 263 - => 'DiffusionCommitTagsController', 264 - ), 265 - 'inline/' => array( 266 - 'edit/(?P<phid>[^/]+)/' => 'DiffusionInlineCommentController', 267 - 'preview/(?P<phid>[^/]+)/' => 268 - 'DiffusionInlineCommentPreviewController', 269 - ), 270 - 'services/' => array( 271 - 'path/' => array( 272 - 'complete/' => 'DiffusionPathCompleteController', 273 - 'validate/' => 'DiffusionPathValidateController', 274 - ), 275 - ), 276 - 'symbol/(?P<name>[^/]+)/' => 'DiffusionSymbolController', 277 - 'external/' => 'DiffusionExternalController', 278 - ), 279 190 280 191 '/daemon/' => array( 281 192 'task/(?P<id>\d+)/' => 'PhabricatorWorkerTaskDetailController', ··· 320 231 'delete/(?P<id>\d+)/' => 'PhabricatorOwnersDeleteController', 321 232 ), 322 233 323 - '/audit/' => array( 324 - '' => 'PhabricatorAuditListController', 325 - 'view/(?P<filter>[^/]+)/(?:(?P<name>[^/]+)/)?' 326 - => 'PhabricatorAuditListController', 327 - 'addcomment/' => 'PhabricatorAuditAddCommentController', 328 - 'preview/(?P<id>\d+)/' => 'PhabricatorAuditPreviewController', 329 - ), 330 - 331 234 '/xhpast/' => array( 332 235 '' => 'PhabricatorXHPASTViewRunController', 333 236 'view/(?P<id>\d+)/' ··· 371 274 'create/' => 'PhabricatorSlowvoteCreateController', 372 275 ), 373 276 374 - // Match "/w/" with slug "/". 375 - '/w(?P<slug>/)' => 'PhrictionDocumentController', 376 - // Match "/w/x/y/z/" with slug "x/y/z/". 377 - '/w/(?P<slug>.+/)' => 'PhrictionDocumentController', 378 - 379 - '/phriction/' => array( 380 - '' => 'PhrictionListController', 381 - 'list/(?P<view>[^/]+)/' => 'PhrictionListController', 382 - 383 - 'history(?P<slug>/)' => 'PhrictionHistoryController', 384 - 'history/(?P<slug>.+/)' => 'PhrictionHistoryController', 385 - 386 - 'edit/(?:(?P<id>\d+)/)?' => 'PhrictionEditController', 387 - 'delete/(?P<id>\d+)/' => 'PhrictionDeleteController', 388 - 389 - 'preview/' => 'PhrictionDocumentPreviewController', 390 - 'diff/(?P<id>\d+)/' => 'PhrictionDiffController', 391 - ), 392 - 393 277 '/phame/' => array( 394 278 '' => 'PhameAllPostListController', 395 279 'post/' => array( ··· 453 337 'clear/' => 'PhabricatorNotificationClearController', 454 338 ), 455 339 456 - '/flag/' => array( 457 - '' => 'PhabricatorFlagListController', 458 - 'view/(?P<view>[^/]+)/' => 'PhabricatorFlagListController', 459 - 'edit/(?P<phid>[^/]+)/' => 'PhabricatorFlagEditController', 460 - 'delete/(?P<id>\d+)/' => 'PhabricatorFlagDeleteController', 461 - ), 462 - 463 340 '/phortune/' => array( 464 341 'stripe/' => array( 465 342 'testpaymentform/' => 'PhortuneStripeTestPaymentFormController', ··· 469 346 '/emailverify/(?P<code>[^/]+)/' => 470 347 'PhabricatorEmailVerificationController', 471 348 472 - ) + $this->getApplicationRoutes(); 349 + ); 473 350 } 474 351 475 352 protected function getResourceURIMapRules() { ··· 481 358 => 'CelerityResourceController', 482 359 ), 483 360 ); 484 - } 485 - 486 - private function getApplicationRoutes() { 487 - $applications = PhabricatorApplication::getAllInstalledApplications(); 488 - $routes = array(); 489 - foreach ($applications as $application) { 490 - $routes += $application->getRoutes(); 491 - } 492 - return $routes; 493 361 } 494 362 495 363 public function buildRequest() {
+12 -1
src/applications/audit/application/PhabricatorApplicationAudit.php
··· 26 26 return '/audit/'; 27 27 } 28 28 29 - 30 29 public function getIconURI() { 31 30 return celerity_get_resource_uri('/rsrc/image/app/app_audit.png'); 31 + } 32 + 33 + public function getRoutes() { 34 + return array( 35 + '/audit/' => array( 36 + '' => 'PhabricatorAuditListController', 37 + 'view/(?P<filter>[^/]+)/(?:(?P<name>[^/]+)/)?' 38 + => 'PhabricatorAuditListController', 39 + 'addcomment/' => 'PhabricatorAuditAddCommentController', 40 + 'preview/(?P<id>\d+)/' => 'PhabricatorAuditPreviewController', 41 + ), 42 + ); 32 43 } 33 44 34 45 public function loadStatus(PhabricatorUser $user) {
+30
src/applications/differential/application/PhabricatorApplicationDifferential.php
··· 36 36 ); 37 37 } 38 38 39 + public function getRoutes() { 40 + return array( 41 + '/D(?P<id>\d+)' => 'DifferentialRevisionViewController', 42 + '/differential/' => array( 43 + '' => 'DifferentialRevisionListController', 44 + 'filter/(?P<filter>\w+)/(?:(?P<username>\w+)/)?' => 45 + 'DifferentialRevisionListController', 46 + 'stats/(?P<filter>\w+)/' => 'DifferentialRevisionStatsController', 47 + 'diff/' => array( 48 + '(?P<id>\d+)/' => 'DifferentialDiffViewController', 49 + 'create/' => 'DifferentialDiffCreateController', 50 + ), 51 + 'changeset/' => 'DifferentialChangesetViewController', 52 + 'revision/edit/(?:(?P<id>\d+)/)?' 53 + => 'DifferentialRevisionEditController', 54 + 'comment/' => array( 55 + 'preview/(?P<id>\d+)/' => 'DifferentialCommentPreviewController', 56 + 'save/' => 'DifferentialCommentSaveController', 57 + 'inline/' => array( 58 + 'preview/(?P<id>\d+)/' => 59 + 'DifferentialInlineCommentPreviewController', 60 + 'edit/(?P<id>\d+)/' => 'DifferentialInlineCommentEditController', 61 + ), 62 + ), 63 + 'subscribe/(?P<action>add|rem)/(?P<id>\d+)/' 64 + => 'DifferentialSubscribeController', 65 + ), 66 + ); 67 + } 68 + 39 69 public function loadStatus(PhabricatorUser $user) { 40 70 $revisions = id(new DifferentialRevisionQuery()) 41 71 ->withResponsibleUsers(array($user->getPHID()))
+40
src/applications/diffusion/application/PhabricatorApplicationDiffusion.php
··· 30 30 return celerity_get_resource_uri('/rsrc/image/app/app_diffusion.png'); 31 31 } 32 32 33 + public function getRoutes() { 34 + return array( 35 + '/r(?P<callsign>[A-Z]+)(?P<commit>[a-z0-9]+)' 36 + => 'DiffusionCommitController', 37 + '/diffusion/' => array( 38 + '' => 'DiffusionHomeController', 39 + '(?P<callsign>[A-Z]+)/' => array( 40 + '' => 'DiffusionRepositoryController', 41 + 42 + 'repository/(?P<dblob>.*)' => 'DiffusionRepositoryController', 43 + 'change/(?P<dblob>.*)' => 'DiffusionChangeController', 44 + 'history/(?P<dblob>.*)' => 'DiffusionHistoryController', 45 + 'browse/(?P<dblob>.*)' => 'DiffusionBrowseController', 46 + 'lastmodified/(?P<dblob>.*)' => 'DiffusionLastModifiedController', 47 + 'diff/' => 'DiffusionDiffController', 48 + 'tags/(?P<dblob>.*)' => 'DiffusionTagListController', 49 + 'branches/(?P<dblob>.*)' => 'DiffusionBranchTableController', 50 + 51 + 'commit/(?P<commit>[a-z0-9]+)/branches/' 52 + => 'DiffusionCommitBranchesController', 53 + 'commit/(?P<commit>[a-z0-9]+)/tags/' 54 + => 'DiffusionCommitTagsController', 55 + ), 56 + 'inline/' => array( 57 + 'edit/(?P<phid>[^/]+)/' => 'DiffusionInlineCommentController', 58 + 'preview/(?P<phid>[^/]+)/' => 59 + 'DiffusionInlineCommentPreviewController', 60 + ), 61 + 'services/' => array( 62 + 'path/' => array( 63 + 'complete/' => 'DiffusionPathCompleteController', 64 + 'validate/' => 'DiffusionPathValidateController', 65 + ), 66 + ), 67 + 'symbol/(?P<name>[^/]+)/' => 'DiffusionSymbolController', 68 + 'external/' => 'DiffusionExternalController', 69 + ), 70 + ); 71 + } 72 + 33 73 } 34 74
+11
src/applications/flag/application/PhabricatorApplicationFlags.php
··· 49 49 return $status; 50 50 } 51 51 52 + public function getRoutes() { 53 + return array( 54 + '/flag/' => array( 55 + '' => 'PhabricatorFlagListController', 56 + 'view/(?P<view>[^/]+)/' => 'PhabricatorFlagListController', 57 + 'edit/(?P<phid>[^/]+)/' => 'PhabricatorFlagEditController', 58 + 'delete/(?P<id>\d+)/' => 'PhabricatorFlagDeleteController', 59 + ), 60 + ); 61 + } 62 + 52 63 } 53 64
+31
src/applications/maniphest/application/PhabricatorApplicationManiphest.php
··· 40 40 ); 41 41 } 42 42 43 + public function getRoutes() { 44 + return array( 45 + '/T(?P<id>\d+)' => 'ManiphestTaskDetailController', 46 + '/maniphest/' => array( 47 + '' => 'ManiphestTaskListController', 48 + 'view/(?P<view>\w+)/' => 'ManiphestTaskListController', 49 + 'report/(?:(?P<view>\w+)/)?' => 'ManiphestReportController', 50 + 'batch/' => 'ManiphestBatchEditController', 51 + 'task/' => array( 52 + 'create/' => 'ManiphestTaskEditController', 53 + 'edit/(?P<id>\d+)/' => 'ManiphestTaskEditController', 54 + 'descriptionchange/(?:(?P<id>\d+)/)?' => 55 + 'ManiphestTaskDescriptionChangeController', 56 + 'descriptionpreview/' => 57 + 'ManiphestTaskDescriptionPreviewController', 58 + ), 59 + 'transaction/' => array( 60 + 'save/' => 'ManiphestTransactionSaveController', 61 + 'preview/(?P<id>\d+)/' => 'ManiphestTransactionPreviewController', 62 + ), 63 + 'export/(?P<key>[^/]+)/' => 'ManiphestExportController', 64 + 'subpriority/' => 'ManiphestSubpriorityController', 65 + 'custom/' => array( 66 + '' => 'ManiphestSavedQueryListController', 67 + 'edit/(?:(?P<id>\d+)/)?' => 'ManiphestSavedQueryEditController', 68 + 'delete/(?P<id>\d+)/' => 'ManiphestSavedQueryDeleteController', 69 + ), 70 + ), 71 + ); 72 + } 73 + 43 74 public function loadStatus(PhabricatorUser $user) { 44 75 $status = array(); 45 76
+22
src/applications/phriction/application/PhabricatorApplicationPhriction.php
··· 30 30 return celerity_get_resource_uri('/rsrc/image/app/app_phriction.png'); 31 31 } 32 32 33 + public function getRoutes() { 34 + return array( 35 + // Match "/w/" with slug "/". 36 + '/w(?P<slug>/)' => 'PhrictionDocumentController', 37 + // Match "/w/x/y/z/" with slug "x/y/z/". 38 + '/w/(?P<slug>.+/)' => 'PhrictionDocumentController', 39 + 40 + '/phriction/' => array( 41 + '' => 'PhrictionListController', 42 + 'list/(?P<view>[^/]+)/' => 'PhrictionListController', 43 + 44 + 'history(?P<slug>/)' => 'PhrictionHistoryController', 45 + 'history/(?P<slug>.+/)' => 'PhrictionHistoryController', 46 + 47 + 'edit/(?:(?P<id>\d+)/)?' => 'PhrictionEditController', 48 + 'delete/(?P<id>\d+)/' => 'PhrictionDeleteController', 49 + 50 + 'preview/' => 'PhrictionDocumentPreviewController', 51 + 'diff/(?P<id>\d+)/' => 'PhrictionDiffController', 52 + ), 53 + ); 54 + } 33 55 34 56 } 35 57