Version 1
[yaffs-website] / vendor / drupal / console / bin / drupal.php
1 <?php
2
3 use Symfony\Component\Console\Input\ArgvInput;
4 use DrupalFinder\DrupalFinder;
5 use Drupal\Console\Core\Utils\ArgvInputReader;
6 use Drupal\Console\Bootstrap\Drupal;
7 use Drupal\Console\Application;
8
9 set_time_limit(0);
10
11 $autoloaders = [];
12
13 if (file_exists(__DIR__ . '/../autoload.local.php')) {
14     include_once __DIR__ . '/../autoload.local.php';
15 } else {
16     $autoloaders = [
17         __DIR__ . '/../../../autoload.php',
18         __DIR__ . '/../vendor/autoload.php'
19     ];
20 }
21
22 foreach ($autoloaders as $file) {
23     if (file_exists($file)) {
24         $autoloader = $file;
25         break;
26     }
27 }
28
29 if (isset($autoloader)) {
30     $autoload = include_once $autoloader;
31 } else {
32     echo ' You must set up the project dependencies using `composer install`' . PHP_EOL;
33     exit(1);
34 }
35
36 $argvInput = new ArgvInput();
37 $debug = $argvInput->hasParameterOption(['--debug']);
38
39 $drupalFinder = new DrupalFinder();
40 if (!$drupalFinder->locateRoot(getcwd())) {
41     echo ' DrupalConsole must be executed within a Drupal Site.'.PHP_EOL;
42
43     exit(1);
44 }
45
46 $composerRoot = $drupalFinder->getComposerRoot();
47 $drupalRoot = $drupalFinder->getDrupalRoot();
48 chdir($drupalRoot);
49
50 $drupal = new Drupal($autoload, $composerRoot, $drupalRoot);
51 $container = $drupal->boot($debug);
52
53 if (!$container) {
54     echo ' Something was wrong. Drupal can not be bootstrap.';
55
56     exit(1);
57 }
58
59 $configuration = $container->get('console.configuration_manager')
60     ->getConfiguration();
61
62 $argvInputReader = new ArgvInputReader();
63 if ($options = $configuration->get('application.options') ?: []) {
64     $argvInputReader->setOptionsFromConfiguration($options);
65 }
66 $argvInputReader->setOptionsAsArgv();
67 $application = new Application($container);
68 $application->setDefaultCommand('about');
69 $application->run();