Security update for Core, with self-updated composer
[yaffs-website] / vendor / drupal / console / bin / drupal.php
index 6c5b26be9bdf9653a1a67d0c64675abc6cb9786f..6070fc633d045b764ff26654195cdd871c47dc3f 100644 (file)
@@ -1,12 +1,18 @@
 <?php
 
-use Drupal\Console\Core\Utils\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;
-use Drupal\Console\Core\Utils\ConfigurationManager;
 
 set_time_limit(0);
+ini_set('display_errors', 1);
+ini_set('display_startup_errors', 1);
+error_reporting(E_ALL);
 
 $autoloaders = [];
 
@@ -33,34 +39,51 @@ if (isset($autoloader)) {
     exit(1);
 }
 
+$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);
 }
 
 chdir($drupalFinder->getDrupalRoot());
-
 $configurationManager = new ConfigurationManager();
 $configuration = $configurationManager
-    ->loadConfigurationFromDirectory($drupalFinder->getComposerRoot());
+    ->loadConfiguration($drupalFinder->getComposerRoot())
+    ->getConfiguration();
 
-$argvInputReader = new ArgvInputReader();
+$debug = $argvInputReader->get('debug', false);
 if ($configuration && $options = $configuration->get('application.options') ?: []) {
     $argvInputReader->setOptionsFromConfiguration($options);
 }
 $argvInputReader->setOptionsAsArgv();
 
-$drupal = new Drupal($autoload, $drupalFinder);
+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);
 }
 
 $application = new Application($container);
-$application->setDefaultCommand('about');
+$application->setDrupal($drupal);
 $application->run();