Skip to content

Commit

Permalink
getDatabaseHelper()
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Jul 31, 2024
1 parent 344fdac commit d8ce76f
Show file tree
Hide file tree
Showing 14 changed files with 22 additions and 43 deletions.
9 changes: 9 additions & 0 deletions src/N98/Magento/Command/AbstractMagentoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use N98\Magento\Application;
use N98\Magento\Command\SubCommand\ConfigBag;
use N98\Magento\Command\SubCommand\SubCommandFactory;
use N98\Util\Console\Helper\DatabaseHelper;
use N98\Util\Console\Helper\IoHelper;
use N98\Util\Console\Helper\MagentoHelper;
use N98\Util\Console\Helper\ParameterHelper;
Expand Down Expand Up @@ -692,6 +693,14 @@ public function addFormatOption(): self
return $this;
}

/**
* @return DatabaseHelper
*/
public function getDatabaseHelper(): DatabaseHelper
{
return $this->getHelper('database');
}

/**
* @return IoHelper
*/
Expand Down
11 changes: 1 addition & 10 deletions src/N98/Magento/Command/Database/AbstractDatabaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use N98\Magento\Command\Database\Compressor\AbstractCompressor;
use N98\Magento\Command\Database\Compressor\Compressor;
use N98\Magento\DbSettings;
use N98\Util\Console\Helper\DatabaseHelper;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -99,14 +98,6 @@ protected function _dsn()
return $this->getDatabaseHelper()->dsn();
}

/**
* @return DatabaseHelper
*/
protected function getDatabaseHelper()
{
return $this->getHelper('database');
}

/**
* @param array $excludes
* @param array $definitions
Expand All @@ -118,6 +109,6 @@ protected function getDatabaseHelper()
*/
protected function resolveTables(array $excludes, array $definitions, array $resolved = [])
{
return $this->getHelper('database')->resolveTables($excludes, $definitions, $resolved);
return $this->getDatabaseHelper()->resolveTables($excludes, $definitions, $resolved);
}
}
4 changes: 1 addition & 3 deletions src/N98/Magento/Command/Database/AbstractShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace N98\Magento\Command\Database;

use Description;
use N98\Util\Console\Helper\DatabaseHelper;
use N98\Util\Filesystem;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -173,8 +172,7 @@ protected function renderTable(array $header, array $rows)
*/
protected function initVariables($variable = null)
{
/** @var DatabaseHelper $database */
$database = $this->getHelper('database');
$database = $this->getDatabaseHelper();
$this->_allVariables = $database->{$this->showMethod}($variable);
}

Expand Down
5 changes: 1 addition & 4 deletions src/N98/Magento/Command/Database/ConsoleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace N98\Magento\Command\Database;

use N98\Util\Console\Helper\DatabaseHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -79,9 +78,7 @@ private function processCommand($command)
*/
private function getMysqlClientToolConnection()
{
/* @var DatabaseHelper $database */
$database = $this->getHelper('database');

$database = $this->getDatabaseHelper();
return $database->getMysqlClientToolConnectionString();
}
}
2 changes: 1 addition & 1 deletion src/N98/Magento/Command/Database/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getHelp(): string
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->getHelper('database')->createDatabase($output);
$this->getDatabaseHelper()->createDatabase($output);
return 0;
}
}
4 changes: 1 addition & 3 deletions src/N98/Magento/Command/Database/DropCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace N98\Magento\Command\Database;

use N98\Util\Console\Helper\DatabaseHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -48,8 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->detectDbSettings($output);

$dialog = $this->getQuestionHelper();
/** @var DatabaseHelper $dbHelper */
$dbHelper = $this->getHelper('database');
$dbHelper = $this->getDatabaseHelper();

if ($input->getOption('force')) {
$shouldDrop = true;
Expand Down
6 changes: 1 addition & 5 deletions src/N98/Magento/Command/Database/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
use InvalidArgumentException;
use N98\Magento\Command\Database\Compressor\Compressor;
use N98\Util\Console\Enabler;
use N98\Util\Console\Helper\DatabaseHelper;
use N98\Util\Exec;
use N98\Util\VerifyOrDie;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand Down Expand Up @@ -183,9 +181,7 @@ private function getTableDefinitions()
$this->commandConfig = $this->getCommandConfig();

if (is_null($this->tableDefinitions)) {
/* @var DatabaseHelper $dbHelper */
$dbHelper = $this->getHelper('database');

$dbHelper = $this->getDatabaseHelper();
$this->tableDefinitions = $dbHelper->getTableDefinitions($this->commandConfig);
}

Expand Down
2 changes: 1 addition & 1 deletion src/N98/Magento/Command/Database/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->detectDbSettings($output);

$this->writeSection($output, 'Import MySQL Database');
$dbHelper = $this->getHelper('database');
$dbHelper = $this->getDatabaseHelper();

$fileName = $this->checkFilename($input);

Expand Down
4 changes: 1 addition & 3 deletions src/N98/Magento/Command/Database/InfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace N98\Magento\Command\Database;

use InvalidArgumentException;
use N98\Util\Console\Helper\DatabaseHelper;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -91,8 +90,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
$settings['JDBC-Connection-String'] = $jdbcConnectionString;

/* @var DatabaseHelper $database */
$database = $this->getHelper('database');
$database = $this->getDatabaseHelper();
$mysqlCliString = 'mysql ' . $database->getMysqlClientToolConnectionString();
$settings['MySQL-Cli-String'] = $mysqlCliString;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->output = $output;
$this->isTypeAllowed();
$this->detectMagento($output);
$this->dbHelper = $this->getHelper('database');
$this->dbHelper = $this->getDatabaseHelper();
$this->showProgress = $input->getOption('format') == null;

if ($input->getOption('table')) {
Expand Down
3 changes: 1 addition & 2 deletions src/N98/Magento/Command/Database/QueryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$query = $this->getOrAskForArgument('query', $input, $output, 'SQL Query');

/** @var \N98\Util\Console\Helper\DatabaseHelper $helper */
$helper = $this->getHelper('database');
$helper = $this->getDatabaseHelper();
$exec = sprintf('mysql %s -e %s', $helper->getMysqlClientToolConnectionString(), escapeshellarg($query));

if ($input->getOption('only-command')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ protected function getColumnType($columnType)
*/
protected function initTableColumns()
{
$dbHelper = $this->getHelper('database');
/* @var \N98\Util\Console\Helper\DatabaseHelper $dbHelper */
/** @var PDO $connection */
$dbHelper = $this->getDatabaseHelper();
$connection = $dbHelper->getConnection($this->_output);
$stmt = $connection->query('SHOW COLUMNS FROM ' . $this->_mageModelTable, PDO::FETCH_ASSOC);
foreach ($stmt as $row) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Locale;
use Mage;
use N98\Magento\Command\AbstractMagentoCommand;
use N98\Util\Console\Helper\DatabaseHelper;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand Down Expand Up @@ -41,8 +40,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return 0;
}

/** @var DatabaseHelper $helper */
$helper = $this->getHelper('database');
$helper = $this->getDatabaseHelper();
$db = $helper->getConnection();

$filename = $input->getArgument('filename');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
namespace N98\Magento\Command\Installer\SubCommand;

use N98\Magento\Command\SubCommand\AbstractSubCommand;
use N98\Util\Console\Helper\DatabaseHelper;
use N98\Util\Database;
use N98\Util\Exec;
use N98\Util\Filesystem;
use N98\Util\OperatingSystem;
use N98\Util\StringTyped;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Process\Process;
Expand Down Expand Up @@ -119,8 +117,7 @@ private function installSampleData(array $demoPackageData): void
$this->config['installationFolder'] . '/magento_*sample_data*sql'
);

/** @var DatabaseHelper $dbHelper */
$dbHelper = $this->command->getHelper('database');
$dbHelper = $this->command->getDatabaseHelper();

if (isset($sampleDataSqlFile[0])) {
$this->output->writeln('<info>Import sample data db data</info>');
Expand Down

0 comments on commit d8ce76f

Please sign in to comment.