More updates to stop using dev or alpha or beta versions.
[yaffs-website] / vendor / drupal / console / bin / drupal.php
index 35c172344b0a0e734305fb650ec03b85df3a18ea..6070fc633d045b764ff26654195cdd871c47dc3f 100644 (file)
@@ -1,12 +1,18 @@
 <?php
 
-use Symfony\Component\Console\Input\ArgvInput;
-use DrupalFinder\DrupalFinder;
+use Symfony\Component\Console\Output\ConsoleOutput;
+use Symfony\Component\Console\Input\ArrayInput;
+use Drupal\Console\Core\Utils\ConfigurationManager;
 use Drupal\Console\Core\Utils\ArgvInputReader;
+use Drupal\Console\Core\Utils\DrupalFinder;
+use Drupal\Console\Core\Style\DrupalStyle;
 use Drupal\Console\Bootstrap\Drupal;
 use Drupal\Console\Application;
 
 set_time_limit(0);
+ini_set('display_errors', 1);
+ini_set('display_startup_errors', 1);
+error_reporting(E_ALL);
 
 $autoloaders = [];
 
@@ -33,37 +39,51 @@ if (isset($autoloader)) {
     exit(1);
 }
 
-$argvInput = new ArgvInput();
-$debug = $argvInput->hasParameterOption(['--debug']);
+$output = new ConsoleOutput();
+$input = new ArrayInput([]);
+$io = new DrupalStyle($input, $output);
+
+$argvInputReader = new ArgvInputReader();
+$root = $argvInputReader->get('root', getcwd());
 
 $drupalFinder = new DrupalFinder();
-if (!$drupalFinder->locateRoot(getcwd())) {
-    echo ' DrupalConsole must be executed within a Drupal Site.'.PHP_EOL;
+if (!$drupalFinder->locateRoot($root)) {
+    $io->error('DrupalConsole must be executed within a Drupal Site.');
 
     exit(1);
 }
 
-$composerRoot = $drupalFinder->getComposerRoot();
-$drupalRoot = $drupalFinder->getDrupalRoot();
-chdir($drupalRoot);
+chdir($drupalFinder->getDrupalRoot());
+$configurationManager = new ConfigurationManager();
+$configuration = $configurationManager
+    ->loadConfiguration($drupalFinder->getComposerRoot())
+    ->getConfiguration();
+
+$debug = $argvInputReader->get('debug', false);
+if ($configuration && $options = $configuration->get('application.options') ?: []) {
+    $argvInputReader->setOptionsFromConfiguration($options);
+}
+$argvInputReader->setOptionsAsArgv();
 
-$drupal = new Drupal($autoload, $composerRoot, $drupalRoot);
-$container = $drupal->boot($debug);
+if ($debug) {
+    $io->writeln(
+        sprintf(
+            '<info>%s</info> version <comment>%s</comment>',
+            Application::NAME,
+            Application::VERSION
+        )
+    );
+}
+
+$drupal = new Drupal($autoload, $drupalFinder, $configurationManager);
+$container = $drupal->boot();
 
 if (!$container) {
-    echo ' Something was wrong. Drupal can not be bootstrap.';
+    $io->error('Something was wrong. Drupal can not be bootstrap.');
 
     exit(1);
 }
 
-$configuration = $container->get('console.configuration_manager')
-    ->getConfiguration();
-
-$argvInputReader = new ArgvInputReader();
-if ($options = $configuration->get('application.options') ?: []) {
-    $argvInputReader->setOptionsFromConfiguration($options);
-}
-$argvInputReader->setOptionsAsArgv();
 $application = new Application($container);
-$application->setDefaultCommand('about');
+$application->setDrupal($drupal);
 $application->run();