-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathdrupal.php
More file actions
140 lines (117 loc) · 4.24 KB
/
drupal.php
File metadata and controls
140 lines (117 loc) · 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
use Drupal\Console\Core\Bootstrap\DrupalConsoleCore;
use Drupal\Console\Core\Style\DrupalStyle;
use Drupal\Console\Core\Utils\ArgvInputReader;
use Drupal\Console\Core\Utils\ConfigurationManager;
use Drupal\Console\Core\Utils\DrupalFinder;
use Drupal\Console\Launcher\Application;
use Drupal\Console\Launcher\Utils\LauncherRemote;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\ConsoleOutput;
set_time_limit(0);
error_reporting(-1);
$autoloaders = [
dirname(__DIR__, 1) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php',
dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'autoload.php',
];
foreach ($autoloaders as $file) {
if (file_exists($file)) {
$autoloader = $file;
break;
}
}
if (isset($autoloader)) {
$autoload = include_once $autoloader;
$launcherRoot = dirname($autoloader, 2);
} else {
echo ' Something is wrong with your drupal.phar archive.'.PHP_EOL.
' Try downloading again by executing from your terminal:'.PHP_EOL.
' curl https://drupalconsole.com/installer -L -o drupal.phar'.PHP_EOL;
exit(1);
}
$argvInputReader = new ArgvInputReader();
$target = $argvInputReader->get('target', null);
$root = $argvInputReader->get('root', getcwd());
$debug = $argvInputReader->get('debug', false);
$command = $argvInputReader->get('command', false);
$drupalFinder = new DrupalFinder();
$drupalFinder->locateRoot($root);
$composerRoot = $drupalFinder->getComposerRoot();
$drupalRoot = $drupalFinder->getDrupalRoot();
$isValidDrupal = ($composerRoot && $drupalRoot)?true:false;
$drupalConsole = new DrupalConsoleCore($launcherRoot);
$container = $drupalConsole->boot();
/* @var ConfigurationManager $configurationManager */
$configurationManager = $container->get('console.configuration_manager');
$configuration = $configurationManager->getConfiguration();
$translator = $container->get('console.translator_manager');
if ($options = $configuration->get('application.options') ?: []) {
$argvInputReader->setOptionsFromConfiguration($options);
}
$targetConfig = [];
if ($target = $argvInputReader->get('target')) {
$targetConfig = $container->get('console.configuration_manager')
->readTarget($target);
$argvInputReader->setOptionsFromTargetConfiguration($targetConfig);
}
$argvInputReader->setOptionsAsArgv();
$output = new ConsoleOutput();
$input = new ArrayInput([]);
$io = new DrupalStyle($input, $output);
if ($target = $argvInputReader->get('target')) {
$configurationManager->loadConfiguration($drupalFinder->getComposerRoot());
$configurationManager->getSites();
$options = $configurationManager->readTarget($target);
if ($options && isset($options['remote'])) {
$launcherRemote = $container->get('console.launcher_remote');
$launch = $launcherRemote->launch($options, $command);
exit(0);
} else {
// @TODO fix and launch local drupal
$root = $options['root'];
$drupalFinder = new DrupalFinder();
$drupalFinder->locateRoot($root);
$isValidDrupal = ($composerRoot && $drupalRoot);
}
}
if ($debug || ($isValidDrupal && $command == 'list')) {
$io->writeln(
sprintf(
'<info>%s</info> version <comment>%s</comment>',
Application::NAME,
Application::VERSION
)
);
}
if ($debug) {
$io->writeln(
sprintf(
'<info>Launcher path:</info> <comment>%s</comment>',
$argv[0]
)
);
}
if ($isValidDrupal) {
$drupalConsoleLauncher = $container->get('console.launcher');
$launch = $drupalConsoleLauncher->launch($drupalFinder);
if (!$launch) {
$message = sprintf(
$translator->trans('application.site.errors.not-installed'),
$argvInputReader->get('root')
);
$io->error($message);
$io->info(
$translator->trans('application.site.errors.execute-composer')
);
$io->commentBlock(
$configuration->get('application.composer.install-console')
);
exit(1);
}
exit(0);
}
$argvInputReader->restoreOriginalArgvValues();
$application = new Application($container);
$application->setDefaultCommand('about');
$application->run();