/** * @param \ZipArchive $zip * @param $install_path * @param $tmp * * @return bool */ public static function copyInstall(\ZipArchive $zip, $install_path, $tmp) { $firstDir = $zip->getNameIndex(0); if (empty($firstDir)) { throw new \RuntimeException("Directory {$firstDir} is missing"); } else { $tmp = realpath($tmp . DS . $firstDir); Folder::rcopy($tmp, $install_path); } return true; }
/** * @param $package */ private function installDemoContent($package) { $demo_dir = $this->destination . DS . $package->install_path . DS . '_demo'; $dest_dir = $this->destination . DS . 'user'; $pages_dir = $dest_dir . DS . 'pages'; if (file_exists($demo_dir)) { // Demo content exists, prompt to install it. $this->output->writeln("<white>Attention: </white><cyan>" . $package->name . "</cyan> contains demo content"); $helper = $this->getHelper('question'); $question = new ConfirmationQuestion('Do you wish to install this demo content? [y|N] ', false); if (!$helper->ask($this->input, $this->output, $question)) { $this->output->writeln(" '- <red>Skipped!</red> "); $this->output->writeln(''); return; } // if pages folder exists in demo if (file_exists($demo_dir . DS . 'pages')) { $pages_backup = 'pages.' . date('m-d-Y-H-i-s'); $question = new ConfirmationQuestion('This will backup your current `user/pages` folder to `user/' . $pages_backup . '`, continue? [y|N]', false); if (!$helper->ask($this->input, $this->output, $question)) { $this->output->writeln(" '- <red>Skipped!</red> "); $this->output->writeln(''); return; } // backup current pages folder if (file_exists($dest_dir)) { if (rename($pages_dir, $dest_dir . DS . $pages_backup)) { $this->output->writeln(" |- Backing up pages... <green>ok</green>"); } else { $this->output->writeln(" |- Backing up pages... <red>failed</red>"); } } } // Confirmation received, copy over the data $this->output->writeln(" |- Installing demo content... <green>ok</green> "); Folder::rcopy($demo_dir, $dest_dir); $this->output->writeln(" '- <green>Success!</green> "); $this->output->writeln(''); } }
/** * */ private function pages() { $this->output->writeln(''); $this->output->writeln('<comment>Pages Initializing</comment>'); // get pages files and initialize if no pages exist $pages_dir = $this->destination . '/user/pages'; $pages_files = array_diff(scandir($pages_dir), array('..', '.')); if (count($pages_files) == 0) { $destination = $this->source . '/user/pages'; Folder::rcopy($destination, $pages_dir); $this->output->writeln(' <cyan>' . $destination . '</cyan> <comment>-></comment> Created'); } }
/** * @param $source_path * @param $install_path * * @return bool */ public static function copyInstall($source_path, $install_path) { if (empty($source_path)) { throw new \RuntimeException("Directory {$source_path} is missing"); } else { Folder::rcopy($source_path, $install_path); } return true; }