Skip to content

Commit 1684aa8

Browse files
Merge pull request #17589 from MauricioFauth/request-get-route
Move `Routing::getCurrentRoute` to `ServerRequest`
2 parents e748722 + eb37038 commit 1684aa8

40 files changed

Lines changed: 216 additions & 194 deletions

index.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,4 @@
3737

3838
Common::run();
3939

40-
Routing::callControllerForRoute(
41-
Common::getRequest(),
42-
Routing::getCurrentRoute(),
43-
Routing::getDispatcher(),
44-
$GLOBALS['containerBuilder']
45-
);
40+
Routing::callControllerForRoute(Common::getRequest(), Routing::getDispatcher(), $GLOBALS['containerBuilder']);

libraries/classes/Common.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ public static function run(): void
9393
$GLOBALS['token_mismatch'] = $GLOBALS['token_mismatch'] ?? null;
9494

9595
$request = self::getRequest();
96-
97-
$route = Routing::getCurrentRoute();
96+
$route = $request->getRoute();
9897

9998
if ($route === '/import-status') {
10099
$GLOBALS['isMinimumCommon'] = true;

libraries/classes/Controllers/Preferences/ExportController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
use PhpMyAdmin\Config\Forms\User\ExportForm;
1010
use PhpMyAdmin\ConfigStorage\Relation;
1111
use PhpMyAdmin\Controllers\AbstractController;
12+
use PhpMyAdmin\Http\ServerRequest;
1213
use PhpMyAdmin\ResponseRenderer;
13-
use PhpMyAdmin\Routing;
1414
use PhpMyAdmin\Template;
1515
use PhpMyAdmin\TwoFactor;
1616
use PhpMyAdmin\Url;
@@ -43,16 +43,14 @@ public function __construct(
4343
$this->config = $config;
4444
}
4545

46-
public function __invoke(): void
46+
public function __invoke(ServerRequest $request): void
4747
{
4848
$GLOBALS['cf'] = $GLOBALS['cf'] ?? null;
4949
$GLOBALS['error'] = $GLOBALS['error'] ?? null;
5050
$GLOBALS['tabHash'] = $GLOBALS['tabHash'] ?? null;
5151
$GLOBALS['hash'] = $GLOBALS['hash'] ?? null;
5252
$GLOBALS['server'] = $GLOBALS['server'] ?? null;
5353

54-
$route = Routing::getCurrentRoute();
55-
5654
$GLOBALS['cf'] = new ConfigFile($this->config->baseSettings);
5755
$this->userPreferences->pageInit($GLOBALS['cf']);
5856

@@ -92,7 +90,7 @@ public function __invoke(): void
9290
$relationParameters = $this->relation->getRelationParameters();
9391

9492
$this->render('preferences/header', [
95-
'route' => $route,
93+
'route' => $request->getRoute(),
9694
'is_saved' => ! empty($_GET['saved']),
9795
'has_config_storage' => $relationParameters->userPreferencesFeature !== null,
9896
]);

libraries/classes/Controllers/Preferences/FeaturesController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
use PhpMyAdmin\Config\Forms\User\FeaturesForm;
1010
use PhpMyAdmin\ConfigStorage\Relation;
1111
use PhpMyAdmin\Controllers\AbstractController;
12+
use PhpMyAdmin\Http\ServerRequest;
1213
use PhpMyAdmin\ResponseRenderer;
13-
use PhpMyAdmin\Routing;
1414
use PhpMyAdmin\Template;
1515
use PhpMyAdmin\TwoFactor;
1616
use PhpMyAdmin\Url;
@@ -43,16 +43,14 @@ public function __construct(
4343
$this->config = $config;
4444
}
4545

46-
public function __invoke(): void
46+
public function __invoke(ServerRequest $request): void
4747
{
4848
$GLOBALS['cf'] = $GLOBALS['cf'] ?? null;
4949
$GLOBALS['error'] = $GLOBALS['error'] ?? null;
5050
$GLOBALS['tabHash'] = $GLOBALS['tabHash'] ?? null;
5151
$GLOBALS['hash'] = $GLOBALS['hash'] ?? null;
5252
$GLOBALS['server'] = $GLOBALS['server'] ?? null;
5353

54-
$route = Routing::getCurrentRoute();
55-
5654
$GLOBALS['cf'] = new ConfigFile($this->config->baseSettings);
5755
$this->userPreferences->pageInit($GLOBALS['cf']);
5856

@@ -92,7 +90,7 @@ public function __invoke(): void
9290
$relationParameters = $this->relation->getRelationParameters();
9391

9492
$this->render('preferences/header', [
95-
'route' => $route,
93+
'route' => $request->getRoute(),
9694
'is_saved' => ! empty($_GET['saved']),
9795
'has_config_storage' => $relationParameters->userPreferencesFeature !== null,
9896
]);

libraries/classes/Controllers/Preferences/ImportController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
use PhpMyAdmin\Config\Forms\User\ImportForm;
1010
use PhpMyAdmin\ConfigStorage\Relation;
1111
use PhpMyAdmin\Controllers\AbstractController;
12+
use PhpMyAdmin\Http\ServerRequest;
1213
use PhpMyAdmin\ResponseRenderer;
13-
use PhpMyAdmin\Routing;
1414
use PhpMyAdmin\Template;
1515
use PhpMyAdmin\TwoFactor;
1616
use PhpMyAdmin\Url;
@@ -43,16 +43,14 @@ public function __construct(
4343
$this->config = $config;
4444
}
4545

46-
public function __invoke(): void
46+
public function __invoke(ServerRequest $request): void
4747
{
4848
$GLOBALS['cf'] = $GLOBALS['cf'] ?? null;
4949
$GLOBALS['error'] = $GLOBALS['error'] ?? null;
5050
$GLOBALS['tabHash'] = $GLOBALS['tabHash'] ?? null;
5151
$GLOBALS['hash'] = $GLOBALS['hash'] ?? null;
5252
$GLOBALS['server'] = $GLOBALS['server'] ?? null;
5353

54-
$route = Routing::getCurrentRoute();
55-
5654
$GLOBALS['cf'] = new ConfigFile($this->config->baseSettings);
5755
$this->userPreferences->pageInit($GLOBALS['cf']);
5856

@@ -92,7 +90,7 @@ public function __invoke(): void
9290
$relationParameters = $this->relation->getRelationParameters();
9391

9492
$this->render('preferences/header', [
95-
'route' => $route,
93+
'route' => $request->getRoute(),
9694
'is_saved' => ! empty($_GET['saved']),
9795
'has_config_storage' => $relationParameters->userPreferencesFeature !== null,
9896
]);

libraries/classes/Controllers/Preferences/MainPanelController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
use PhpMyAdmin\Config\Forms\User\MainForm;
1010
use PhpMyAdmin\ConfigStorage\Relation;
1111
use PhpMyAdmin\Controllers\AbstractController;
12+
use PhpMyAdmin\Http\ServerRequest;
1213
use PhpMyAdmin\ResponseRenderer;
13-
use PhpMyAdmin\Routing;
1414
use PhpMyAdmin\Template;
1515
use PhpMyAdmin\TwoFactor;
1616
use PhpMyAdmin\Url;
@@ -43,16 +43,14 @@ public function __construct(
4343
$this->config = $config;
4444
}
4545

46-
public function __invoke(): void
46+
public function __invoke(ServerRequest $request): void
4747
{
4848
$GLOBALS['cf'] = $GLOBALS['cf'] ?? null;
4949
$GLOBALS['error'] = $GLOBALS['error'] ?? null;
5050
$GLOBALS['tabHash'] = $GLOBALS['tabHash'] ?? null;
5151
$GLOBALS['hash'] = $GLOBALS['hash'] ?? null;
5252
$GLOBALS['server'] = $GLOBALS['server'] ?? null;
5353

54-
$route = Routing::getCurrentRoute();
55-
5654
$GLOBALS['cf'] = new ConfigFile($this->config->baseSettings);
5755
$this->userPreferences->pageInit($GLOBALS['cf']);
5856

@@ -92,7 +90,7 @@ public function __invoke(): void
9290
$relationParameters = $this->relation->getRelationParameters();
9391

9492
$this->render('preferences/header', [
95-
'route' => $route,
93+
'route' => $request->getRoute(),
9694
'is_saved' => ! empty($_GET['saved']),
9795
'has_config_storage' => $relationParameters->userPreferencesFeature !== null,
9896
]);

libraries/classes/Controllers/Preferences/ManageController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
use PhpMyAdmin\Controllers\AbstractController;
1212
use PhpMyAdmin\Core;
1313
use PhpMyAdmin\File;
14+
use PhpMyAdmin\Http\ServerRequest;
1415
use PhpMyAdmin\Message;
1516
use PhpMyAdmin\ResponseRenderer;
16-
use PhpMyAdmin\Routing;
1717
use PhpMyAdmin\Template;
1818
use PhpMyAdmin\ThemeManager;
1919
use PhpMyAdmin\UserPreferences;
@@ -65,7 +65,7 @@ public function __construct(
6565
$this->config = $config;
6666
}
6767

68-
public function __invoke(): void
68+
public function __invoke(ServerRequest $request): void
6969
{
7070
$GLOBALS['cf'] = $GLOBALS['cf'] ?? null;
7171
$GLOBALS['error'] = $GLOBALS['error'] ?? null;
@@ -79,7 +79,7 @@ public function __invoke(): void
7979
$GLOBALS['params'] = $GLOBALS['params'] ?? null;
8080
$GLOBALS['query'] = $GLOBALS['query'] ?? null;
8181

82-
$route = Routing::getCurrentRoute();
82+
$route = $request->getRoute();
8383

8484
$GLOBALS['cf'] = new ConfigFile($this->config->baseSettings);
8585
$this->userPreferences->pageInit($GLOBALS['cf']);

libraries/classes/Controllers/Preferences/NavigationController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
use PhpMyAdmin\Config\Forms\User\NaviForm;
1010
use PhpMyAdmin\ConfigStorage\Relation;
1111
use PhpMyAdmin\Controllers\AbstractController;
12+
use PhpMyAdmin\Http\ServerRequest;
1213
use PhpMyAdmin\ResponseRenderer;
13-
use PhpMyAdmin\Routing;
1414
use PhpMyAdmin\Template;
1515
use PhpMyAdmin\TwoFactor;
1616
use PhpMyAdmin\Url;
@@ -43,16 +43,14 @@ public function __construct(
4343
$this->config = $config;
4444
}
4545

46-
public function __invoke(): void
46+
public function __invoke(ServerRequest $request): void
4747
{
4848
$GLOBALS['cf'] = $GLOBALS['cf'] ?? null;
4949
$GLOBALS['error'] = $GLOBALS['error'] ?? null;
5050
$GLOBALS['tabHash'] = $GLOBALS['tabHash'] ?? null;
5151
$GLOBALS['hash'] = $GLOBALS['hash'] ?? null;
5252
$GLOBALS['server'] = $GLOBALS['server'] ?? null;
5353

54-
$route = Routing::getCurrentRoute();
55-
5654
$GLOBALS['cf'] = new ConfigFile($this->config->baseSettings);
5755
$this->userPreferences->pageInit($GLOBALS['cf']);
5856

@@ -92,7 +90,7 @@ public function __invoke(): void
9290
$relationParameters = $this->relation->getRelationParameters();
9391

9492
$this->render('preferences/header', [
95-
'route' => $route,
93+
'route' => $request->getRoute(),
9694
'is_saved' => ! empty($_GET['saved']),
9795
'has_config_storage' => $relationParameters->userPreferencesFeature !== null,
9896
]);

libraries/classes/Controllers/Preferences/SqlController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
use PhpMyAdmin\Config\Forms\User\SqlForm;
1010
use PhpMyAdmin\ConfigStorage\Relation;
1111
use PhpMyAdmin\Controllers\AbstractController;
12+
use PhpMyAdmin\Http\ServerRequest;
1213
use PhpMyAdmin\ResponseRenderer;
13-
use PhpMyAdmin\Routing;
1414
use PhpMyAdmin\Template;
1515
use PhpMyAdmin\TwoFactor;
1616
use PhpMyAdmin\Url;
@@ -43,16 +43,14 @@ public function __construct(
4343
$this->config = $config;
4444
}
4545

46-
public function __invoke(): void
46+
public function __invoke(ServerRequest $request): void
4747
{
4848
$GLOBALS['cf'] = $GLOBALS['cf'] ?? null;
4949
$GLOBALS['error'] = $GLOBALS['error'] ?? null;
5050
$GLOBALS['tabHash'] = $GLOBALS['tabHash'] ?? null;
5151
$GLOBALS['hash'] = $GLOBALS['hash'] ?? null;
5252
$GLOBALS['server'] = $GLOBALS['server'] ?? null;
5353

54-
$route = Routing::getCurrentRoute();
55-
5654
$GLOBALS['cf'] = new ConfigFile($this->config->baseSettings);
5755
$this->userPreferences->pageInit($GLOBALS['cf']);
5856

@@ -92,7 +90,7 @@ public function __invoke(): void
9290
$relationParameters = $this->relation->getRelationParameters();
9391

9492
$this->render('preferences/header', [
95-
'route' => $route,
93+
'route' => $request->getRoute(),
9694
'is_saved' => ! empty($_GET['saved']),
9795
'has_config_storage' => $relationParameters->userPreferencesFeature !== null,
9896
]);

libraries/classes/Controllers/Preferences/TwoFactorController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
use PhpMyAdmin\ConfigStorage\Relation;
88
use PhpMyAdmin\Controllers\AbstractController;
9+
use PhpMyAdmin\Http\ServerRequest;
910
use PhpMyAdmin\Message;
1011
use PhpMyAdmin\ResponseRenderer;
11-
use PhpMyAdmin\Routing;
1212
use PhpMyAdmin\Template;
1313
use PhpMyAdmin\TwoFactor;
1414

@@ -26,14 +26,12 @@ public function __construct(ResponseRenderer $response, Template $template, Rela
2626
$this->relation = $relation;
2727
}
2828

29-
public function __invoke(): void
29+
public function __invoke(ServerRequest $request): void
3030
{
31-
$route = Routing::getCurrentRoute();
32-
3331
$relationParameters = $this->relation->getRelationParameters();
3432

3533
echo $this->template->render('preferences/header', [
36-
'route' => $route,
34+
'route' => $request->getRoute(),
3735
'is_saved' => ! empty($_GET['saved']),
3836
'has_config_storage' => $relationParameters->userPreferencesFeature !== null,
3937
]);

0 commit comments

Comments
 (0)