annotate core/lib/Drupal/Core/Command/QuickStartCommand.php @ 19:fa3358dc1485 tip

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