/**
  * init the DeployManagers
  *
  * @param Composer    $composer
  * @param IOInterface $io
  */
 protected function initDeployManager(Composer $composer, IOInterface $io, EventManager $eventManager)
 {
     $this->deployManagers['core'] = new DeployManager($eventManager);
     $this->deployManagers['module'] = new DeployManager($eventManager);
     $this->deployManagers['module']->setSortPriority($this->getSortPriority($composer));
     if ($this->config->hasAutoAppendGitignore()) {
         $gitIgnoreLocation = sprintf('%s/.gitignore', $this->config->getMagentoRootDir());
         $eventManager->listen('post-package-deploy', new GitIgnoreListener(new GitIgnore($gitIgnoreLocation)));
     }
     if ($this->io->isDebug()) {
         $eventManager->listen('pre-package-deploy', function (PackageDeployEvent $event) use($io) {
             $io->write('Start magento deploy for ' . $event->getDeployEntry()->getPackageName());
         });
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // init repos
     $composer = $this->getComposer();
     $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
     $dm = $composer->getDownloadManager();
     $im = $composer->getInstallationManager();
     /**
      * @var $moduleInstaller \MagentoHackathon\Composer\Magento\Installer
      */
     $moduleInstaller = $im->getInstaller("magento-module");
     $eventManager = new EventManager();
     $deployManager = new DeployManager($eventManager);
     $io = $this->getIo();
     if ($io->isDebug()) {
         $eventManager->listen('pre-package-deploy', function (PackageDeployEvent $event) use($io) {
             $io->write('Start magento deploy for ' . $event->getDeployEntry()->getPackageName());
         });
     }
     $extra = $composer->getPackage()->getExtra();
     $sortPriority = isset($extra['magento-deploy-sort-priority']) ? $extra['magento-deploy-sort-priority'] : array();
     $deployManager->setSortPriority($sortPriority);
     $moduleInstaller->setDeployManager($deployManager);
     foreach ($installedRepo->getPackages() as $package) {
         if ($input->getOption('verbose')) {
             $output->writeln($package->getName());
             $output->writeln($package->getType());
         }
         if ($package->getType() != "magento-module") {
             continue;
         }
         if ($input->getOption('verbose')) {
             $output->writeln("package {$package->getName()} recognized");
         }
         $strategy = $moduleInstaller->getDeployStrategy($package);
         if ($input->getOption('verbose')) {
             $output->writeln("used " . get_class($strategy) . " as deploy strategy");
         }
         $strategy->setMappings($moduleInstaller->getParser($package)->getMappings());
         $deployManagerEntry = new Entry();
         $deployManagerEntry->setPackageName($package->getName());
         $deployManagerEntry->setDeployStrategy($strategy);
         $deployManager->addPackage($deployManagerEntry);
     }
     $deployManager->doDeploy();
     return;
 }
 /**
  * @param InstalledPackage[] $packagesToRemove
  */
 public function doRemoves(array $packagesToRemove)
 {
     foreach ($packagesToRemove as $remove) {
         $this->eventManager->dispatch(new PackageUnInstallEvent('pre-package-uninstall', $remove));
         $this->unInstallStrategy->unInstall($remove->getInstalledFiles());
         $this->eventManager->dispatch(new PackageUnInstallEvent('post-package-uninstall', $remove));
         $this->installedPackageRepository->remove($remove);
     }
 }
 /**
  * Deploy all the queued packages
  */
 public function doDeploy()
 {
     $this->sortPackages();
     /** @var Entry $package */
     foreach ($this->packages as $package) {
         $this->eventManager->dispatch(new PackageDeployEvent('pre-package-deploy', $package));
         $package->getDeployStrategy()->deploy();
         $this->eventManager->dispatch(new PackageDeployEvent('post-package-deploy', $package));
     }
 }
Exemple #5
0
 protected function applyEvents(EventManager $eventManager)
 {
     if ($this->config->hasAutoAppendGitignore()) {
         $gitIgnoreLocation = sprintf('%s/.gitignore', $this->config->getMagentoRootDir());
         $gitIgnore = new GitIgnoreListener(new GitIgnore($gitIgnoreLocation));
         $eventManager->listen('post-package-deploy', [$gitIgnore, 'addNewInstalledFiles']);
         $eventManager->listen('post-package-uninstall', [$gitIgnore, 'removeUnInstalledFiles']);
     }
     $io = $this->io;
     if ($this->io->isDebug()) {
         $eventManager->listen('pre-package-deploy', function (PackageDeployEvent $event) use($io) {
             $io->write('Start magento deploy for ' . $event->getDeployEntry()->getPackageName());
         });
     }
 }