Commit 4b9da747 authored by Marco Pivetta's avatar Marco Pivetta

#598 - Minor CS/cleanups in the DBAL CLI runner

parent be370575
...@@ -21,6 +21,10 @@ use Symfony\Component\Console\Helper\HelperSet; ...@@ -21,6 +21,10 @@ use Symfony\Component\Console\Helper\HelperSet;
use Doctrine\DBAL\Tools\Console\ConsoleRunner; use Doctrine\DBAL\Tools\Console\ConsoleRunner;
$files = array(__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php'); $files = array(__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php');
$loader = null;
$cwd = getcwd();
$directories = array($cwd, $cwd . DIRECTORY_SEPARATOR . 'config');
$configFile = null;
foreach ($files as $file) { foreach ($files as $file) {
if (file_exists($file)) { if (file_exists($file)) {
...@@ -30,13 +34,10 @@ foreach ($files as $file) { ...@@ -30,13 +34,10 @@ foreach ($files as $file) {
} }
} }
if (! $loader) { if ( ! $loader) {
throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?'); throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?');
} }
$directories = array(getcwd(), getcwd() . DIRECTORY_SEPARATOR . 'config');
$configFile = null;
foreach ($directories as $directory) { foreach ($directories as $directory) {
$configFile = $directory . DIRECTORY_SEPARATOR . 'cli-config.php'; $configFile = $directory . DIRECTORY_SEPARATOR . 'cli-config.php';
...@@ -47,22 +48,24 @@ foreach ($directories as $directory) { ...@@ -47,22 +48,24 @@ foreach ($directories as $directory) {
if ( ! file_exists($configFile)) { if ( ! file_exists($configFile)) {
ConsoleRunner::printCliConfigTemplate(); ConsoleRunner::printCliConfigTemplate();
exit(1); exit(1);
} }
if ( ! is_readable($configFile)) { if ( ! is_readable($configFile)) {
echo 'Configuration file [' . $configFile . '] does not have read permission.' . PHP_EOL; echo 'Configuration file [' . $configFile . '] does not have read permission.' . PHP_EOL;
exit(1); exit(1);
} }
$commands = array(); $commands = array();
$helperSet = require $configFile; $helperSet = require $configFile;
if ( ! ($helperSet instanceof HelperSet)) { if ( ! $helperSet instanceof HelperSet) {
foreach ($GLOBALS as $helperSetCandidate) { foreach ($GLOBALS as $helperSetCandidate) {
if ($helperSetCandidate instanceof HelperSet) { if ($helperSetCandidate instanceof HelperSet) {
$helperSet = $helperSetCandidate; $helperSet = $helperSetCandidate;
break; break;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment