diff options
author | Kamil Tekiela <tekiela246@gmail.com> | 2022-08-17 21:15:40 +0300 |
---|---|---|
committer | Kamil Tekiela <tekiela246@gmail.com> | 2022-08-17 21:21:33 +0300 |
commit | 094422186869ddf65e8713cf8ea3dbb2bb147f13 (patch) | |
tree | 7a653a92e740967a3283f1626ae78aaed28343e7 /libraries/classes | |
parent | 6d91494935781808fba3ff2686cbdb349a7173f1 (diff) |
Extract moveBackToCallingScript
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
Diffstat (limited to 'libraries/classes')
-rw-r--r-- | libraries/classes/Controllers/Table/ReplaceController.php | 120 |
1 files changed, 45 insertions, 75 deletions
diff --git a/libraries/classes/Controllers/Table/ReplaceController.php b/libraries/classes/Controllers/Table/ReplaceController.php index 6b61cf12de..a431b51fd1 100644 --- a/libraries/classes/Controllers/Table/ReplaceController.php +++ b/libraries/classes/Controllers/Table/ReplaceController.php @@ -343,42 +343,7 @@ final class ReplaceController extends AbstractController $gotoInclude = '/table/change'; } - $GLOBALS['active_page'] = $gotoInclude; - - if ($gotoInclude === '/sql') { - /** @var SqlController $controller */ - $controller = $GLOBALS['containerBuilder']->get(SqlController::class); - $controller($request); - - return; - } - - if ($gotoInclude === '/database/sql') { - /** @var DatabaseSqlController $controller */ - $controller = $GLOBALS['containerBuilder']->get(DatabaseSqlController::class); - $controller($request); - - return; - } - - if ($gotoInclude === '/table/change') { - /** @var ChangeController $controller */ - $controller = $GLOBALS['containerBuilder']->get(ChangeController::class); - $controller($request); - - return; - } - - if ($gotoInclude === '/table/sql') { - /** @var TableSqlController $controller */ - $controller = $GLOBALS['containerBuilder']->get(TableSqlController::class); - $controller($request); - - return; - } - - /** @psalm-suppress UnresolvableInclude */ - include ROOT_PATH . Core::securePath($gotoInclude); + $this->moveBackToCallingScript($gotoInclude, $request); return; } @@ -456,8 +421,6 @@ final class ReplaceController extends AbstractController $this->addScriptFiles(['vendor/jquery/additional-methods.js', 'table/change.js']); - $GLOBALS['active_page'] = $gotoInclude; - /** * If user asked for "and then Insert another new row" we have to remove * WHERE clause information so that /table/change does not go back @@ -467,43 +430,7 @@ final class ReplaceController extends AbstractController unset($_POST['where_clause']); } - if ($gotoInclude === '/sql') { - /** @var SqlController $controller */ - $controller = $GLOBALS['containerBuilder']->get(SqlController::class); - $controller($request); - - return; - } - - if ($gotoInclude === '/database/sql') { - /** @var DatabaseSqlController $controller */ - $controller = $GLOBALS['containerBuilder']->get(DatabaseSqlController::class); - $controller($request); - - return; - } - - if ($gotoInclude === '/table/change') { - /** @var ChangeController $controller */ - $controller = $GLOBALS['containerBuilder']->get(ChangeController::class); - $controller($request); - - return; - } - - if ($gotoInclude === '/table/sql') { - /** @var TableSqlController $controller */ - $controller = $GLOBALS['containerBuilder']->get(TableSqlController::class); - $controller($request); - - return; - } - - /** - * Load target page. - */ - /** @psalm-suppress UnresolvableInclude */ - require ROOT_PATH . Core::securePath($gotoInclude); + $this->moveBackToCallingScript($gotoInclude, $request); } private function doTransformations(array $mimeMap): void @@ -587,4 +514,47 @@ final class ReplaceController extends AbstractController $this->response->addJSON('message', $GLOBALS['message']); $this->response->addJSON($extra_data); } + + private function moveBackToCallingScript(string $gotoInclude, ServerRequest $request): void + { + $GLOBALS['active_page'] = $gotoInclude; + + if ($gotoInclude === '/sql') { + /** @var SqlController $controller */ + $controller = $GLOBALS['containerBuilder']->get(SqlController::class); + $controller($request); + + return; + } + + if ($gotoInclude === '/database/sql') { + /** @var DatabaseSqlController $controller */ + $controller = $GLOBALS['containerBuilder']->get(DatabaseSqlController::class); + $controller($request); + + return; + } + + if ($gotoInclude === '/table/change') { + /** @var ChangeController $controller */ + $controller = $GLOBALS['containerBuilder']->get(ChangeController::class); + $controller($request); + + return; + } + + if ($gotoInclude === '/table/sql') { + /** @var TableSqlController $controller */ + $controller = $GLOBALS['containerBuilder']->get(TableSqlController::class); + $controller($request); + + return; + } + + /** + * Load target page. + */ + /** @psalm-suppress UnresolvableInclude */ + require ROOT_PATH . Core::securePath($gotoInclude); + } } |