X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole-core%2Fsrc%2FCommand%2FInitCommand.php;fp=vendor%2Fdrupal%2Fconsole-core%2Fsrc%2FCommand%2FInitCommand.php;h=d1a409e0245282a0c263671f26ab1f7fcfe8da82;hp=9da25d3ee1c35e754878074a209d6075739e17a6;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/drupal/console-core/src/Command/InitCommand.php b/vendor/drupal/console-core/src/Command/InitCommand.php index 9da25d3ee..d1a409e02 100644 --- a/vendor/drupal/console-core/src/Command/InitCommand.php +++ b/vendor/drupal/console-core/src/Command/InitCommand.php @@ -10,14 +10,12 @@ namespace Drupal\Console\Core\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Process\ProcessBuilder; use Symfony\Component\Finder\Finder; -use Symfony\Component\Console\Command\Command; -use Drupal\Console\Core\Command\Shared\CommandTrait; use Drupal\Console\Core\Utils\ConfigurationManager; use Drupal\Console\Core\Generator\InitGenerator; use Drupal\Console\Core\Utils\ShowFile; -use Drupal\Console\Core\Style\DrupalStyle; /** * Class InitCommand @@ -26,8 +24,6 @@ use Drupal\Console\Core\Style\DrupalStyle; */ class InitCommand extends Command { - use CommandTrait; - /** * @var ShowFile */ @@ -63,6 +59,11 @@ class InitCommand extends Command 'generate_chain' => false ]; + private $directories = [ + 'chain', + 'sites', + ]; + /** * InitCommand constructor. * @@ -120,14 +121,13 @@ class InitCommand extends Command */ protected function interact(InputInterface $input, OutputInterface $output) { - $io = new DrupalStyle($input, $output); $destination = $input->getOption('destination'); $autocomplete = $input->getOption('autocomplete'); $configuration = $this->configurationManager->getConfiguration(); if (!$destination) { if ($this->appRoot && $this->consoleRoot) { - $destination = $io->choice( + $destination = $this->getIo()->choice( $this->trans('commands.init.questions.destination'), $this->configurationManager->getConfigurationDirectories() ); @@ -139,43 +139,43 @@ class InitCommand extends Command $input->setOption('destination', $destination); } - $this->configParameters['language'] = $io->choiceNoList( + $this->configParameters['language'] = $this->getIo()->choiceNoList( $this->trans('commands.init.questions.language'), array_keys($configuration->get('application.languages')) ); - $this->configParameters['temp'] = $io->ask( + $this->configParameters['temp'] = $this->getIo()->ask( $this->trans('commands.init.questions.temp'), '/tmp' ); - $this->configParameters['learning'] = $io->confirm( + $this->configParameters['chain'] = $this->getIo()->confirm( $this->trans('commands.init.questions.chain'), false ); - $this->configParameters['sites'] = $io->confirm( + $this->configParameters['sites'] = $this->getIo()->confirm( $this->trans('commands.init.questions.sites'), false ); - $this->configParameters['chain'] = $io->confirm( + $this->configParameters['learning'] = $this->getIo()->confirm( $this->trans('commands.init.questions.learning'), false ); - $this->configParameters['generate_inline'] = $io->confirm( + $this->configParameters['generate_inline'] = $this->getIo()->confirm( $this->trans('commands.init.questions.generate-inline'), false ); - $this->configParameters['generate_chain'] = $io->confirm( + $this->configParameters['generate_chain'] = $this->getIo()->confirm( $this->trans('commands.init.questions.generate-chain'), false ); if (!$autocomplete) { - $autocomplete = $io->confirm( + $autocomplete = $this->getIo()->confirm( $this->trans('commands.init.questions.autocomplete'), false ); @@ -188,7 +188,6 @@ class InitCommand extends Command */ protected function execute(InputInterface $input, OutputInterface $output) { - $io = new DrupalStyle($input, $output); $copiedFiles = []; $destination = $input->getOption('destination'); $autocomplete = $input->getOption('autocomplete'); @@ -200,9 +199,8 @@ class InitCommand extends Command $finder = new Finder(); $finder->in( sprintf( - '%s%s/config/dist/', - $this->configurationManager->getApplicationDirectory(), - DRUPAL_CONSOLE_CORE + '%sdist/', + $this->configurationManager->getVendorCoreRoot() ) ); if (!$this->configParameters['chain']) { @@ -215,9 +213,8 @@ class InitCommand extends Command foreach ($finder as $configFile) { $sourceFile = sprintf( - '%s%s/config/dist/%s', - $this->configurationManager->getApplicationDirectory(), - DRUPAL_CONSOLE_CORE, + '%sdist/%s', + $this->configurationManager->getVendorCoreRoot(), $configFile->getRelativePathname() ); @@ -227,14 +224,21 @@ class InitCommand extends Command $configFile->getRelativePathname() ); + $fs = new Filesystem(); + foreach ($this->directories as $directory) { + if (!$fs->exists($destination.$directory)) { + $fs->mkdir($destination.$directory); + } + } + if ($this->copyFile($sourceFile, $destinationFile, $override)) { $copiedFiles[] = $destinationFile; } } if ($copiedFiles) { - $this->showFile->copiedFiles($io, $copiedFiles, false); - $io->newLine(); + $this->showFile->copiedFiles($this->getIo(), $copiedFiles, false); + $this->getIo()->newLine(); } $executableName = null; @@ -248,15 +252,15 @@ class InitCommand extends Command $process->stop(); } - $this->generator->generate( - $this->configurationManager->getConsoleDirectory(), - $executableName, - $override, - $destination, - $this->configParameters - ); + $this->generator->generate([ + 'user_home' => $this->configurationManager->getConsoleDirectory(), + 'executable_name' => $executableName, + 'override' => $override, + 'destination' => $destination, + 'config_parameters' => $this->configParameters, + ]); - $io->writeln($this->trans('application.messages.autocomplete')); + $this->getIo()->writeln($this->trans('application.messages.autocomplete')); return 0; }