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;
use Doctrine\DBAL\Tools\Console\ConsoleRunner;
$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) {
if (file_exists($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`?');
}
$directories = array(getcwd(), getcwd() . DIRECTORY_SEPARATOR . 'config');
$configFile = null;
foreach ($directories as $directory) {
$configFile = $directory . DIRECTORY_SEPARATOR . 'cli-config.php';
......@@ -47,22 +48,24 @@ foreach ($directories as $directory) {
if ( ! file_exists($configFile)) {
ConsoleRunner::printCliConfigTemplate();
exit(1);
}
if ( ! is_readable($configFile)) {
echo 'Configuration file [' . $configFile . '] does not have read permission.' . PHP_EOL;
exit(1);
}
$commands = array();
$helperSet = require $configFile;
if ( ! ($helperSet instanceof HelperSet)) {
if ( ! $helperSet instanceof HelperSet) {
foreach ($GLOBALS as $helperSetCandidate) {
if ($helperSetCandidate instanceof HelperSet) {
$helperSet = $helperSetCandidate;
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