Skip to content

Commit

Permalink
Create SchemaExportController controller
Browse files Browse the repository at this point in the history
Moves schema export entry point logic to the SchemaExportController and
removes the entry point file.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed Dec 22, 2019
1 parent 07a2715 commit eea4e8e
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 40 deletions.
59 changes: 59 additions & 0 deletions libraries/classes/Controllers/SchemaExportController.php
@@ -0,0 +1,59 @@
<?php
/**
* @package PhpMyAdmin\Controllers
*/
declare(strict_types=1);

namespace PhpMyAdmin\Controllers;

use PhpMyAdmin\Export;
use PhpMyAdmin\Relation;
use PhpMyAdmin\Util;

/**
* Schema export handler
*
* @package PhpMyAdmin\Controllers
*/
class SchemaExportController
{
/** @var Export */
private $export;

/** @var Relation */
private $relation;

/**
* @param Export $export A Export instance.
* @param Relation $relation A Relation instance.
*/
public function __construct(Export $export, Relation $relation)
{
$this->export = $export;
$this->relation = $relation;
}

/**
* @return void
*/
public function index(): void
{
global $cfgRelation;

/**
* get all variables needed for exporting relational schema
* in $cfgRelation
*/
$cfgRelation = $this->relation->getRelationsParam();

if (! isset($_POST['export_type'])) {
Util::checkParameters(['export_type']);
}

/**
* Include the appropriate Schema Class depending on $export_type
* default is PDF
*/
$this->export->processExportSchema($_POST['export_type']);
}
}
37 changes: 0 additions & 37 deletions libraries/entry_points/schema_export.php

This file was deleted.

7 changes: 5 additions & 2 deletions libraries/routes.php
Expand Up @@ -34,6 +34,7 @@
use PhpMyAdmin\Controllers\NavigationController;
use PhpMyAdmin\Controllers\NormalizationController;
use PhpMyAdmin\Controllers\PhpInfoController;
use PhpMyAdmin\Controllers\SchemaExportController;
use PhpMyAdmin\Controllers\Server\BinlogController;
use PhpMyAdmin\Controllers\Server\CollationsController;
use PhpMyAdmin\Controllers\Server\DatabasesController;
Expand Down Expand Up @@ -323,8 +324,10 @@
require_once ROOT_PATH . 'libraries/entry_points/preferences/twofactor.php';
});
});
$routes->addRoute(['GET', 'POST'], '/schema_export', function () {
require_once ROOT_PATH . 'libraries/entry_points/schema_export.php';
$routes->addRoute(['GET', 'POST'], '/schema-export', function () use ($containerBuilder) {
/** @var SchemaExportController $controller */
$controller = $containerBuilder->get(SchemaExportController::class);
$controller->index();
});
$routes->addGroup('/server', function (RouteCollector $routes) use ($containerBuilder, $response) {
$routes->addRoute(['GET', 'POST'], '/binlog', function () use ($containerBuilder, $response) {
Expand Down
6 changes: 6 additions & 0 deletions services_controllers.yml
Expand Up @@ -245,6 +245,12 @@ services:
dbi: '@dbi'
template: '@template'

PhpMyAdmin\Controllers\SchemaExportController:
class: 'PhpMyAdmin\Controllers\SchemaExportController'
arguments:
export: '@export'
relation: '@relation'

PhpMyAdmin\Controllers\Server\DatabasesController:
class: 'PhpMyAdmin\Controllers\Server\DatabasesController'
arguments:
Expand Down
2 changes: 1 addition & 1 deletion templates/database/designer/schema_export.twig
@@ -1,4 +1,4 @@
<form method="post" action="{{ url('/schema_export') }}" class="disableAjax" id="id_export_pages">
<form method="post" action="{{ url('/schema-export') }}" class="disableAjax" id="id_export_pages">
<fieldset>
{{ get_hidden_inputs(db) }}
<label>{% trans 'Select Export Relational Type' %}</label>
Expand Down

0 comments on commit eea4e8e

Please sign in to comment.