diff --git a/system/src/Grav/Console/Gpm/InstallCommand.php b/system/src/Grav/Console/Gpm/InstallCommand.php index fd015a0e8..7c2eb0581 100644 --- a/system/src/Grav/Console/Gpm/InstallCommand.php +++ b/system/src/Grav/Console/Gpm/InstallCommand.php @@ -206,8 +206,34 @@ class InstallCommand extends Command $this->output->writeln(''); $method_name = 'process'.$method; - $this->$method_name($package); + + $this->installDemoContent($package); + } + + + private function installDemoContent($package) + { + $demo_dir = $this->destination . DS . $package->install_path . DS . '_demo'; + + if (file_exists($demo_dir)) { + // Demo content exists, prompt to install it. + $this->output->writeln("Attention: ".$package->name . " contains demo content"); + $helper = $this->getHelper('question'); + $question = new ConfirmationQuestion('Do you wish to install this demo content? (DANGER: May merge or overwrite existing user data) [y|N]', false); + + if (!$helper->ask($this->input, $this->output, $question)) { + $this->output->writeln(" '- Skipped! "); + $this->output->writeln(''); + return; + } + + // Confirmation received, copy over the data + $this->output->writeln(" |- Installing demo content... ok "); + Utils::rcopy($demo_dir, $this->destination . DS . 'user'); + $this->output->writeln(" '- Success! "); + $this->output->writeln(''); + } } /**