public function downloadMagento(InputInterface $input, OutputInterface $output)
{
try {
$package = $this->createComposerPackageByConfig($this->config['magentoVersionData']);
$this->config['magentoPackage'] = $package;
if (file_exists($this->config['installationFolder'] . '/app/Mage.php')) {
$output->writeln('<error>A magento installation already exists in this folder </error>');
return false;
}
$composer = $this->getComposer($input, $output);
$targetFolder = $this->getTargetFolderByType($composer, $package, $this->config['installationFolder']);
$this->config['magentoPackage'] = $this->downloadByComposerConfig($input, $output, $package, $targetFolder, true);
if ($this->isSourceTypeRepository($package->getSourceType())) {
$filesystem = new \N98\Util\Filesystem();
$filesystem->recursiveCopy($targetFolder, $this->config['installationFolder'], array('.git', '.hg'));
} else {
$filesystem = new \Composer\Util\Filesystem();
$filesystem->copyThenRemove($this->config['installationFolder'] . '/_n98_magerun_download', $this->config['installationFolder']);
}
if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
// Patch installer
$this->patchMagentoInstallerForPHP54($this->config['installationFolder']);
}
} catch (Exception $e) {
$output->writeln('<error>' . $e->getMessage() . '</error>');
return false;
}
return true;
}