Mercurial > hg > isophonics-drupal-site
comparison core/lib/Drupal/Core/Command/QuickStartCommand.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Core\Command; | |
4 | |
5 use Symfony\Component\Console\Command\Command; | |
6 use Symfony\Component\Console\Input\ArrayInput; | |
7 use Symfony\Component\Console\Input\InputArgument; | |
8 use Symfony\Component\Console\Input\InputInterface; | |
9 use Symfony\Component\Console\Input\InputOption; | |
10 use Symfony\Component\Console\Output\OutputInterface; | |
11 | |
12 /** | |
13 * Installs a Drupal site and starts a webserver for local testing/development. | |
14 * | |
15 * Wraps 'install' and 'server' commands. | |
16 * | |
17 * @internal | |
18 * This command makes no guarantee of an API for Drupal extensions. | |
19 * | |
20 * @see \Drupal\Core\Command\InstallCommand | |
21 * @see \Drupal\Core\Command\ServerCommand | |
22 */ | |
23 class QuickStartCommand extends Command { | |
24 | |
25 /** | |
26 * {@inheritdoc} | |
27 */ | |
28 protected function configure() { | |
29 $this->setName('quick-start') | |
30 ->setDescription('Installs a Drupal site and runs a web server. This is not meant for production and might be too simple for custom development. It is a quick and easy way to get Drupal running.') | |
31 ->addArgument('install-profile', InputArgument::OPTIONAL, 'Install profile to install the site in.') | |
32 ->addOption('langcode', NULL, InputOption::VALUE_OPTIONAL, 'The language to install the site in. Defaults to en.', 'en') | |
33 ->addOption('site-name', NULL, InputOption::VALUE_OPTIONAL, 'Set the site name. Defaults to Drupal.', 'Drupal') | |
34 ->addOption('host', NULL, InputOption::VALUE_OPTIONAL, 'Provide a host for the server to run on. Defaults to 127.0.0.1.', '127.0.0.1') | |
35 ->addOption('port', NULL, InputOption::VALUE_OPTIONAL, 'Provide a port for the server to run on. Will be determined automatically if none supplied.') | |
36 ->addOption('suppress-login', 's', InputOption::VALUE_NONE, 'Disable opening a login URL in a browser.') | |
37 ->addUsage('demo_umami --langcode fr') | |
38 ->addUsage('standard --site-name QuickInstall --host localhost --port 8080') | |
39 ->addUsage('minimal --host my-site.com --port 80'); | |
40 | |
41 parent::configure(); | |
42 } | |
43 | |
44 /** | |
45 * {@inheritdoc} | |
46 */ | |
47 protected function execute(InputInterface $input, OutputInterface $output) { | |
48 $command = $this->getApplication()->find('install'); | |
49 | |
50 $arguments = [ | |
51 'command' => 'install', | |
52 'install-profile' => $input->getArgument('install-profile'), | |
53 '--langcode' => $input->getOption('langcode'), | |
54 '--site-name' => $input->getOption('site-name'), | |
55 ]; | |
56 | |
57 $installInput = new ArrayInput($arguments); | |
58 $returnCode = $command->run($installInput, $output); | |
59 | |
60 if ($returnCode === 0) { | |
61 $command = $this->getApplication()->find('server'); | |
62 $arguments = [ | |
63 'command' => 'server', | |
64 '--host' => $input->getOption('host'), | |
65 '--port' => $input->getOption('port'), | |
66 ]; | |
67 if ($input->getOption('suppress-login')) { | |
68 $arguments['--suppress-login'] = TRUE; | |
69 } | |
70 $serverInput = new ArrayInput($arguments); | |
71 $returnCode = $command->run($serverInput, $output); | |
72 } | |
73 return $returnCode; | |
74 } | |
75 | |
76 } |