forked from hechoendrupal/drupal-console-launcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrupal.php
More file actions
91 lines (69 loc) · 2.62 KB
/
drupal.php
File metadata and controls
91 lines (69 loc) · 2.62 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
<?php
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Drupal\Console\Bootstrap\DrupalConsoleCore;
use Drupal\Console\Utils\ArgvInputReader;
use Drupal\Console\Style\DrupalStyle;
use Drupal\ConsoleLauncher\Application;
set_time_limit(0);
$pharRoot = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR;
$pharAutoload = $pharRoot.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
if (file_exists($pharAutoload)) {
$autoload = include_once $pharAutoload;
} else {
echo ' Something goes 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);
}
$drupalConsole = new DrupalConsoleCore($pharRoot);
$container = $drupalConsole->boot();
$configuration = $container->get('console.configuration_manager')
->getConfiguration();
$translator = $container->get('console.translator_manager');
$argvInputReader = new ArgvInputReader();
if ($options = $configuration->get('application.options') ?: []) {
$argvInputReader->setOptionsFromConfiguration($options);
}
if ($target = $argvInputReader->get('target')) {
$targetConfig = $container->get('console.configuration_manager')
->readTarget($target);
$argvInputReader->setOptionsFromTargetConfiguration($targetConfig);
}
$argvInputReader->setOptionsAsArgv();
if ($argvInputReader->get('remote', false)) {
/*
* Execute command via ssh
* Relocate remote execution to this project
*/
exit(0);
}
$output = new ConsoleOutput();
$input = new ArrayInput([]);
$io = new DrupalStyle($input, $output);
$drupalChecker = $container->get('console.drupal_checker');
$isValidDrupal = $drupalChecker->isValidRoot($argvInputReader->get('root'), true);
if ($isValidDrupal) {
$drupalConsoleLauncher = $container->get('console.launcher');
$launch = $drupalConsoleLauncher->launch($argvInputReader->get('root'));
if (!$launch) {
/* Read message from translation file. */
$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();