/** * @param PackageInterface $package * @param string $sourceDir * @return Parser * @throws \ErrorException */ public function make(PackageInterface $package, $sourceDir) { $parser = $this->parserFactory->make($package, $sourceDir); if ($this->config->hasPathMappingTranslations()) { $translations = $this->config->getPathMappingTranslations(); return new PathTranslationParser($parser, $translations); } return $parser; }
public static function initMagentoRootDir(ProjectConfig $projectConfig, \Composer\IO\IOInterface $io, \Composer\Util\Filesystem $filesystem, $vendorDir) { if (false === $projectConfig->hasMagentoRootDir()) { $projectConfig->setMagentoRootDir($io->ask(sprintf('please define your magento root dir [%s]', ProjectConfig::DEFAULT_MAGENTO_ROOT_DIR), ProjectConfig::DEFAULT_MAGENTO_ROOT_DIR)); } $magentoRootDirPath = $projectConfig->getMagentoRootDir(); $magentoRootDir = new \SplFileInfo($magentoRootDirPath); if (!is_dir($magentoRootDirPath) && $io->askConfirmation('magento root dir "' . $magentoRootDirPath . '" missing! create now? [Y,n] ')) { $filesystem->ensureDirectoryExists($magentoRootDir); $io->write('magento root dir "' . $magentoRootDirPath . '" created'); } if (!is_dir($magentoRootDirPath)) { $dir = self::joinFilePath($vendorDir, $magentoRootDirPath); } }
/** * @param PackageInterface $package * @param string $packageSourcePath * @return DeploystrategyAbstract */ public function make(PackageInterface $package, $packageSourcePath) { $strategyName = $this->config->getModuleSpecificDeployStrategy($package->getName()); $ns = '\\MagentoHackathon\\Composer\\Magento\\Deploystrategy\\'; $className = $ns . ucfirst($strategyName); if (!class_exists($className)) { $className = $ns . 'Symlink'; } $strategy = new $className($packageSourcePath, realpath($this->config->getMagentoRootDir())); $strategy->setIgnoredMappings($this->config->getModuleSpecificDeployIgnores($package->getName())); $strategy->setIsForced($this->config->getMagentoForceByPackageName($package->getName())); $mappingParser = $this->parserFactory->make($package, $packageSourcePath); $strategy->setMappings($mappingParser->getMappings()); return $strategy; }
/** * @return ModuleManager */ protected function getModuleManager() { if (null === $this->moduleManager) { $this->moduleManager = new ModuleManager(new InstalledPackageFileSystemRepository(rtrim($this->composer->getConfig()->get(self::VENDOR_DIR_KEY), '/') . '/installed.json', new InstalledPackageDumper()), $this->getEventManager(), $this->config, new UnInstallStrategy($this->filesystem, $this->config->getMagentoRootDir()), new InstallStrategyFactory($this->config, new ParserFactory($this->config))); } return $this->moduleManager; }
/** * @param PackageInterface $package * @return string */ private function getPackageSourceDirectory(PackageInterface $package) { $path = sprintf("%s/%s", $this->config->getVendorDir(), $package->getPrettyName()); $targetDir = $package->getTargetDir(); if ($targetDir) { $path = sprintf("%s/%s", $path, $targetDir); } $path = realpath($path); return $path; }
protected function deployLibraries() { $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getPackages(); $autoloadDirectories = array(); $libraryPath = $this->config->getLibraryPath(); if ($libraryPath === null) { if ($this->io->isDebug()) { $this->io->write('jump over deployLibraries as no Magento libraryPath is set'); } return; } $vendorDir = rtrim($this->composer->getConfig()->get('vendor-dir'), '/'); $filesystem = $this->filesystem; $filesystem->removeDirectory($libraryPath); $filesystem->ensureDirectoryExists($libraryPath); foreach ($packages as $package) { /** @var PackageInterface $package */ $packageConfig = $this->config->getLibraryConfigByPackagename($package->getName()); if ($packageConfig === null) { continue; } if (!isset($packageConfig['autoload'])) { $packageConfig['autoload'] = array('/'); } foreach ($packageConfig['autoload'] as $path) { $autoloadDirectories[] = $libraryPath . '/' . $package->getName() . "/" . $path; } if ($this->io->isDebug()) { $this->io->write('Magento deployLibraries executed for ' . $package->getName()); } $libraryTargetPath = $libraryPath . '/' . $package->getName(); $filesystem->removeDirectory($libraryTargetPath); $filesystem->ensureDirectoryExists($libraryTargetPath); $this->copyRecursive($vendorDir . '/' . $package->getPrettyName(), $libraryTargetPath); } $autoloadGenerator = new AutoloadGenerator(new EventDispatcher($this->composer, $this->io)); $classmap = ClassMapGenerator::createMap($libraryPath); $executable = $this->composer->getConfig()->get('bin-dir') . '/phpab'; if (!file_exists($executable)) { $executable = $this->composer->getConfig()->get('vendor-dir') . '/theseer/autoload/composer/bin/phpab'; } if (file_exists($executable)) { if ($this->io->isDebug()) { $this->io->write('Magento deployLibraries executes autoload generator'); } $process = new Process($executable . " -o {$libraryPath}/autoload.php " . implode(' ', $autoloadDirectories)); $process->run(); } else { if ($this->io->isDebug()) { $this->io->write('Magento deployLibraries autoload generator not availabel, you should require "theseer/autoload"'); var_dump($executable, getcwd()); } } }
/** * @param PackageInterface $package * @param string $sourceDir * @return Parser * @throws \ErrorException */ public function make(PackageInterface $package, $sourceDir) { $moduleSpecificMap = $this->config->getMagentoMapOverwrite(); if (isset($moduleSpecificMap[$package->getName()])) { $map = $moduleSpecificMap[$package->getName()]; return new MapParser($map); } $extra = $package->getExtra(); if (isset($extra['map'])) { return new MapParser($extra['map']); } if (isset($extra['package-xml'])) { return new PackageXmlParser(sprintf('%s/%s', $sourceDir, $extra['package-xml'])); } $modmanFile = sprintf('%s/modman', $sourceDir); if (file_exists($modmanFile)) { return new ModmanParser($modmanFile); } throw new \ErrorException(sprintf('Unable to find deploy strategy for module: "%s" no known mapping' . PHP_EOL . 'sourceDir: "%s"', $package->getName(), $sourceDir)); }
/** * @param PackageInterface $package * @param string $packageSourcePath * @return DeploystrategyAbstract */ public function make(PackageInterface $package, $packageSourcePath) { $strategyName = $this->config->getDeployStrategy(); if ($this->config->hasDeployStrategyOverwrite()) { $moduleSpecificDeployStrategies = $this->config->getDeployStrategyOverwrite(); if (isset($moduleSpecificDeployStrategies[$package->getName()])) { $strategyName = $moduleSpecificDeployStrategies[$package->getName()]; } } if (!isset(static::$strategies[$strategyName])) { $className = static::$strategies['symlink']; } else { $className = static::$strategies[$strategyName]; } $strategy = new $className($packageSourcePath, realpath($this->config->getMagentoRootDir())); $strategy->setIgnoredMappings($this->config->getModuleSpecificDeployIgnores($package->getName())); $strategy->setIsForced($this->config->getMagentoForceByPackageName($package->getName())); return $strategy; }
/** * deploy Libraries */ protected function deployLibraries() { $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getPackages(); $autoloadDirectories = array(); $libraryPath = $this->config->getLibraryPath(); if ($libraryPath === null) { $this->writeDebug('jump over deployLibraries as no Magento libraryPath is set'); return; } $vendorDir = rtrim($this->composer->getConfig()->get(self::VENDOR_DIR_KEY), '/'); $this->filesystem->removeDirectory($libraryPath); $this->filesystem->ensureDirectoryExists($libraryPath); foreach ($packages as $package) { /** @var PackageInterface $package */ $packageConfig = $this->config->getLibraryConfigByPackagename($package->getName()); if ($packageConfig === null) { continue; } if (!isset($packageConfig['autoload'])) { $packageConfig['autoload'] = array('/'); } foreach ($packageConfig['autoload'] as $path) { $autoloadDirectories[] = $libraryPath . '/' . $package->getName() . "/" . $path; } $this->writeDebug(sprintf('Magento deployLibraries executed for %s', $package->getName())); $libraryTargetPath = $libraryPath . '/' . $package->getName(); $this->filesystem->removeDirectory($libraryTargetPath); $this->filesystem->ensureDirectoryExists($libraryTargetPath); $this->copyRecursive($vendorDir . '/' . $package->getPrettyName(), $libraryTargetPath); } if (false !== ($executable = $this->getTheseerAutoloadExecutable())) { $this->writeDebug('Magento deployLibraries executes autoload generator'); $params = $this->getTheseerAutoloadParams($libraryPath, $autoloadDirectories); $process = new Process($executable . $params); $process->run(); } }
/** * @param ProjectConfig $config * @return $this */ public static function fromConfig(ProjectConfig $config) { return new self($config->getMagentoRootDir() . '/app/Mage.php', $config); }