Use DI for the MultSubmits class
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
f388297af2
commit
71f8a04c69
@ -22,6 +22,9 @@ use function preg_replace;
|
||||
*/
|
||||
class MultSubmits
|
||||
{
|
||||
/** @var DatabaseInterface */
|
||||
private $dbi;
|
||||
|
||||
/** @var Transformations */
|
||||
private $transformations;
|
||||
|
||||
@ -34,13 +37,25 @@ class MultSubmits
|
||||
/** @var Template */
|
||||
private $template;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->transformations = new Transformations();
|
||||
$relation = new Relation($GLOBALS['dbi']);
|
||||
$this->relationCleanup = new RelationCleanup($GLOBALS['dbi'], $relation);
|
||||
$this->operations = new Operations($GLOBALS['dbi'], $relation);
|
||||
$this->template = new Template();
|
||||
/**
|
||||
* @param DatabaseInterface $dbi DatabaseInterface instance.
|
||||
* @param Template $template Template instance.
|
||||
* @param Transformations $transformations Transformations instance.
|
||||
* @param RelationCleanup $relationCleanup RelationCleanup instance.
|
||||
* @param Operations $operations Operations instance.
|
||||
*/
|
||||
public function __construct(
|
||||
$dbi,
|
||||
Template $template,
|
||||
Transformations $transformations,
|
||||
RelationCleanup $relationCleanup,
|
||||
Operations $operations
|
||||
) {
|
||||
$this->dbi = $dbi;
|
||||
$this->template = $template;
|
||||
$this->transformations = $transformations;
|
||||
$this->relationCleanup = $relationCleanup;
|
||||
$this->operations = $operations;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -353,9 +368,9 @@ class MultSubmits
|
||||
if ($runParts && ! $copyTable) {
|
||||
$sqlQuery .= $aQuery . ';' . "\n";
|
||||
if ($queryType != 'drop_db') {
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
$this->dbi->selectDb($db);
|
||||
}
|
||||
$result = $GLOBALS['dbi']->query($aQuery);
|
||||
$result = $this->dbi->query($aQuery);
|
||||
|
||||
if ($queryType == 'drop_db') {
|
||||
$this->transformations->clear($selected[$i]);
|
||||
|
||||
@ -40,9 +40,14 @@ $table_type = $_POST['table_type'] ?? $table_type ?? null;
|
||||
$to_prefix = $_POST['to_prefix'] ?? $to_prefix ?? null;
|
||||
$url_query = $_POST['url_query'] ?? $url_query ?? null;
|
||||
|
||||
$response = Response::getInstance();
|
||||
$multSubmits = new MultSubmits();
|
||||
$template = new Template();
|
||||
/** @var Response $response */
|
||||
$response = $containerBuilder->get('response');
|
||||
|
||||
/** @var Template $template */
|
||||
$template = $containerBuilder->get('template');
|
||||
|
||||
/** @var MultSubmits $multSubmits */
|
||||
$multSubmits = $containerBuilder->get('mult_submits');
|
||||
|
||||
$action = $action ?? '';
|
||||
|
||||
|
||||
@ -125,6 +125,18 @@ return [
|
||||
'@service_container',
|
||||
],
|
||||
],
|
||||
'mult_submits' =>
|
||||
[
|
||||
'class' => \PhpMyAdmin\MultSubmits::class,
|
||||
'arguments' =>
|
||||
[
|
||||
'dbi' => '@dbi',
|
||||
'template' => '@template',
|
||||
'transformations' => '@transformations',
|
||||
'relationCleanup' => '@relation_cleanup',
|
||||
'operations' => '@operations',
|
||||
],
|
||||
],
|
||||
'navigation' =>
|
||||
[
|
||||
'class' => PhpMyAdmin\Navigation\Navigation::class,
|
||||
|
||||
@ -7,6 +7,11 @@ declare(strict_types=1);
|
||||
namespace PhpMyAdmin\Tests;
|
||||
|
||||
use PhpMyAdmin\MultSubmits;
|
||||
use PhpMyAdmin\Operations;
|
||||
use PhpMyAdmin\Relation;
|
||||
use PhpMyAdmin\RelationCleanup;
|
||||
use PhpMyAdmin\Template;
|
||||
use PhpMyAdmin\Transformations;
|
||||
use PhpMyAdmin\Url;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@ -65,7 +70,14 @@ class MultSubmitsTest extends TestCase
|
||||
|
||||
$GLOBALS['dbi'] = $dbi;
|
||||
|
||||
$this->multSubmits = new MultSubmits();
|
||||
$relation = new Relation($GLOBALS['dbi']);
|
||||
$this->multSubmits = new MultSubmits(
|
||||
$GLOBALS['dbi'],
|
||||
new Template(),
|
||||
new Transformations(),
|
||||
new RelationCleanup($GLOBALS['dbi'], $relation),
|
||||
new Operations($GLOBALS['dbi'], $relation)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user