X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FCommand%2FQuickStartCommand.php;fp=web%2Fcore%2Flib%2FDrupal%2FCore%2FCommand%2FQuickStartCommand.php;h=690b20eb3b261bf869b6b5fbaac3ef1ce8dd3c00;hp=0000000000000000000000000000000000000000;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/lib/Drupal/Core/Command/QuickStartCommand.php b/web/core/lib/Drupal/Core/Command/QuickStartCommand.php new file mode 100644 index 000000000..690b20eb3 --- /dev/null +++ b/web/core/lib/Drupal/Core/Command/QuickStartCommand.php @@ -0,0 +1,76 @@ +setName('quick-start') + ->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.') + ->addArgument('install-profile', InputArgument::OPTIONAL, 'Install profile to install the site in.') + ->addOption('langcode', NULL, InputOption::VALUE_OPTIONAL, 'The language to install the site in. Defaults to en.', 'en') + ->addOption('site-name', NULL, InputOption::VALUE_OPTIONAL, 'Set the site name. Defaults to Drupal.', 'Drupal') + ->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') + ->addOption('port', NULL, InputOption::VALUE_OPTIONAL, 'Provide a port for the server to run on. Will be determined automatically if none supplied.') + ->addOption('suppress-login', 's', InputOption::VALUE_NONE, 'Disable opening a login URL in a browser.') + ->addUsage('demo_umami --langcode fr') + ->addUsage('standard --site-name QuickInstall --host localhost --port 8080') + ->addUsage('minimal --host my-site.com --port 80'); + + parent::configure(); + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) { + $command = $this->getApplication()->find('install'); + + $arguments = [ + 'command' => 'install', + 'install-profile' => $input->getArgument('install-profile'), + '--langcode' => $input->getOption('langcode'), + '--site-name' => $input->getOption('site-name'), + ]; + + $installInput = new ArrayInput($arguments); + $returnCode = $command->run($installInput, $output); + + if ($returnCode === 0) { + $command = $this->getApplication()->find('server'); + $arguments = [ + 'command' => 'server', + '--host' => $input->getOption('host'), + '--port' => $input->getOption('port'), + ]; + if ($input->getOption('suppress-login')) { + $arguments['--suppress-login'] = TRUE; + } + $serverInput = new ArrayInput($arguments); + $returnCode = $command->run($serverInput, $output); + } + return $returnCode; + } + +}