6070fc633d045b764ff26654195cdd871c47dc3f
[yaffs-website] / vendor / drupal / console / bin / drupal.php
1 <?php
2
3 use Symfony\Component\Console\Output\ConsoleOutput;
4 use Symfony\Component\Console\Input\ArrayInput;
5 use Drupal\Console\Core\Utils\ConfigurationManager;
6 use Drupal\Console\Core\Utils\ArgvInputReader;
7 use Drupal\Console\Core\Utils\DrupalFinder;
8 use Drupal\Console\Core\Style\DrupalStyle;
9 use Drupal\Console\Bootstrap\Drupal;
10 use Drupal\Console\Application;
11
12 set_time_limit(0);
13 ini_set('display_errors', 1);
14 ini_set('display_startup_errors', 1);
15 error_reporting(E_ALL);
16
17 $autoloaders = [];
18
19 if (file_exists(__DIR__ . '/../autoload.local.php')) {
20     include_once __DIR__ . '/../autoload.local.php';
21 } else {
22     $autoloaders = [
23         __DIR__ . '/../../../autoload.php',
24         __DIR__ . '/../vendor/autoload.php'
25     ];
26 }
27
28 foreach ($autoloaders as $file) {
29     if (file_exists($file)) {
30         $autoloader = $file;
31         break;
32     }
33 }
34
35 if (isset($autoloader)) {
36     $autoload = include_once $autoloader;
37 } else {
38     echo ' You must set up the project dependencies using `composer install`' . PHP_EOL;
39     exit(1);
40 }
41
42 $output = new ConsoleOutput();
43 $input = new ArrayInput([]);
44 $io = new DrupalStyle($input, $output);
45
46 $argvInputReader = new ArgvInputReader();
47 $root = $argvInputReader->get('root', getcwd());
48
49 $drupalFinder = new DrupalFinder();
50 if (!$drupalFinder->locateRoot($root)) {
51     $io->error('DrupalConsole must be executed within a Drupal Site.');
52
53     exit(1);
54 }
55
56 chdir($drupalFinder->getDrupalRoot());
57 $configurationManager = new ConfigurationManager();
58 $configuration = $configurationManager
59     ->loadConfiguration($drupalFinder->getComposerRoot())
60     ->getConfiguration();
61
62 $debug = $argvInputReader->get('debug', false);
63 if ($configuration && $options = $configuration->get('application.options') ?: []) {
64     $argvInputReader->setOptionsFromConfiguration($options);
65 }
66 $argvInputReader->setOptionsAsArgv();
67
68 if ($debug) {
69     $io->writeln(
70         sprintf(
71             '<info>%s</info> version <comment>%s</comment>',
72             Application::NAME,
73             Application::VERSION
74         )
75     );
76 }
77
78 $drupal = new Drupal($autoload, $drupalFinder, $configurationManager);
79 $container = $drupal->boot();
80
81 if (!$container) {
82     $io->error('Something was wrong. Drupal can not be bootstrap.');
83
84     exit(1);
85 }
86
87 $application = new Application($container);
88 $application->setDrupal($drupal);
89 $application->run();