Skip to content

Commit

Permalink
Create ThemesController
Browse files Browse the repository at this point in the history
Moves themes entry point logic to the ThemesController and removes the
themes.php entry point file.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Dec 5, 2019
1 parent 2bae3aa commit be95d29
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 38 deletions.
37 changes: 37 additions & 0 deletions libraries/classes/Controllers/ThemesController.php
@@ -0,0 +1,37 @@
<?php
/**
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);

namespace PhpMyAdmin\Controllers;

use PhpMyAdmin\ThemeManager;

/**
* Displays list of themes.
* @package PhpMyAdmin\Controllers
*/
class ThemesController extends AbstractController
{
/**
* @return string
*/
public function index(): string
{
$this->response->getFooter()->setMinimal();
$header = $this->response->getHeader();
$header->setBodyId('bodythemes');
$header->setTitle('phpMyAdmin - ' . __('Theme'));
$header->disableMenuAndConsole();

return $this->template->render('themes', [
'version' => preg_replace(
'/([0-9]*)\.([0-9]*)\..*/',
'\1_\2',
PMA_VERSION
),
'previews' => ThemeManager::getInstance()->getPrintPreviews(),
]);
}
}
36 changes: 0 additions & 36 deletions libraries/entry_points/themes.php

This file was deleted.

7 changes: 5 additions & 2 deletions libraries/routes.php
Expand Up @@ -36,6 +36,7 @@
use PhpMyAdmin\Controllers\Server\Status\StatusController;
use PhpMyAdmin\Controllers\Server\Status\VariablesController as StatusVariables;
use PhpMyAdmin\Controllers\Server\VariablesController;
use PhpMyAdmin\Controllers\ThemesController;
use PhpMyAdmin\Controllers\TransformationOverviewController;
use PhpMyAdmin\Controllers\UserPasswordController;
use PhpMyAdmin\Controllers\VersionCheckController;
Expand Down Expand Up @@ -542,8 +543,10 @@
require_once ROOT_PATH . 'libraries/entry_points/table/zoom_select.php';
});
});
$routes->get('/themes', function () {
require_once ROOT_PATH . 'libraries/entry_points/themes.php';
$routes->get('/themes', function () use ($containerBuilder, $response) {
/** @var ThemesController $controller */
$controller = $containerBuilder->get(ThemesController::class);
$response->addHTML($controller->index());
});
$routes->addGroup('/transformation', function (RouteCollector $routes) use ($containerBuilder, $response) {
$routes->addRoute(['GET', 'POST'], '/overview', function () use ($containerBuilder, $response) {
Expand Down
7 changes: 7 additions & 0 deletions services_controllers.yml
Expand Up @@ -393,6 +393,13 @@ services:
transformations: '@transformations'
create_add_field: '@create_add_field'

PhpMyAdmin\Controllers\ThemesController:
class: 'PhpMyAdmin\Controllers\ThemesController'
arguments:
response: '@response'
dbi: '@dbi'
template: '@template'

PhpMyAdmin\Controllers\TransformationOverviewController:
class: 'PhpMyAdmin\Controllers\TransformationOverviewController'
arguments:
Expand Down

0 comments on commit be95d29

Please sign in to comment.