/** * Uninstall theme from code base * * @param OutputInterface $output * @param array $themePaths * @return void */ public function uninstallCode(OutputInterface $output, array $themePaths) { $output->writeln('<info>Removing ' . implode(', ', $themePaths) . ' from Magento codebase'); $packageNames = []; foreach ($themePaths as $themePath) { $packageNames[] = $this->themePackageInfo->getPackageName($themePath); } $output->writeln($this->remove->remove($packageNames)); }
/** * Run 'composer remove' to remove code * * @param OutputInterface $output * @param array $modules * @return void */ public function uninstallCode(OutputInterface $output, array $modules) { $output->writeln('<info>Removing code from Magento codebase:</info>'); $packages = []; /** @var \Magento\Framework\Module\PackageInfo $packageInfo */ $packageInfo = $this->objectManager->get('Magento\\Framework\\Module\\PackageInfoFactory')->create(); foreach ($modules as $module) { $packages[] = $packageInfo->getPackageName($module); } $this->remove->remove($packages); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $languages = $input->getArgument(self::PACKAGE_ARGUMENT); $packagesToRemove = []; $dependencies = $this->dependencyChecker->checkDependencies($languages, true); foreach ($languages as $package) { if (!$this->validate($package)) { $output->writeln("<info>Package {$package} is not a Magento language and will be skipped.</info>"); } else { if (sizeof($dependencies[$package]) > 0) { $output->writeln("<info>Package {$package} has dependencies and will be skipped.</info>"); } else { $packagesToRemove[] = $package; } } } if ($packagesToRemove !== []) { if ($input->getOption(self::BACKUP_CODE_OPTION)) { $backupRestore = $this->backupRollbackFactory->create($output); $backupRestore->codeBackup(time()); } else { $output->writeln('<info>You are removing language package without a code backup.</info>'); } $output->writeln($this->remove->remove($packagesToRemove)); $this->cache->clean(); } else { $output->writeln('<info>Nothing is removed.</info>'); } }
public function testRemove() { $composerAppFactory = $this->getMock('Magento\\Framework\\Composer\\MagentoComposerApplicationFactory', [], [], '', false); $composerApp = $this->getMock('Magento\\Composer\\MagentoComposerApplication', [], [], '', false); $composerApp->expects($this->once())->method('runComposerCommand'); $composerAppFactory->expects($this->once())->method('create')->willReturn($composerApp); $remove = new Remove($composerAppFactory); $remove->remove(['magento/package-a', 'magento/package-b']); }
public function testRemove() { $composerApp = $this->getMock('Composer\\Console\\Application', ['setAutoExit', 'resetComposer', 'run'], [], '', false); $directoryList = $this->getMock('Magento\\Framework\\App\\Filesystem\\DirectoryList', [], [], '', false); $directoryList->expects($this->once())->method('getRoot'); $directoryList->expects($this->once())->method('getPath')->with(DirectoryList::CONFIG)->willReturn(BP . '/app/etc'); $composerApp->expects($this->once())->method('setAutoExit')->with(false); $composerApp->expects($this->once())->method('run'); $remove = new Remove($composerApp, $directoryList); $remove->remove(['magento/package-a', 'magento/package-b']); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $themePaths = $input->getArgument(self::INPUT_KEY_THEMES); $validationMessages = $this->validate($themePaths); if (!empty($validationMessages)) { $output->writeln($validationMessages); return; } $isThemeInUseMessages = $this->themeValidator->validateIsThemeInUse($themePaths); if (!empty($isThemeInUseMessages)) { $output->writeln($isThemeInUseMessages); return; } $childThemeCheckMessages = $this->checkChildTheme($themePaths); if (!empty($childThemeCheckMessages)) { $output->writeln($childThemeCheckMessages); return; } $dependencyMessages = $this->checkDependencies($themePaths); if (!empty($dependencyMessages)) { $output->writeln($dependencyMessages); return; } try { $output->writeln('<info>Enabling maintenance mode</info>'); $this->maintenanceMode->set(true); if ($input->getOption(self::INPUT_KEY_BACKUP_CODE)) { $time = time(); $codeBackup = $this->backupRollbackFactory->create($output); $codeBackup->codeBackup($time); } $output->writeln('<info>Removing ' . implode(', ', $themePaths) . ' from database'); $this->removeFromDb($themePaths); $output->writeln('<info>Removing ' . implode(', ', $themePaths) . ' from Magento codebase'); $themePackages = []; foreach ($themePaths as $themePath) { $themePackages[] = $this->getPackageName($themePath); } $this->remove->remove($themePackages); $this->cleanup($input, $output); $output->writeln('<info>Disabling maintenance mode</info>'); $this->maintenanceMode->set(false); } catch (\Exception $e) { $output->writeln('<error>' . $e->getMessage() . '</error>'); $output->writeln('<error>Please disable maintenance mode after you resolved above issues</error>'); } }
/** * Run 'composer remove' to remove code * * @param array $modules * @return void */ private function removeCode(array $modules) { $packages = []; foreach ($modules as $module) { $packages[] = $this->packageInfo->getPackageName($module); } $this->remove->remove($packages); }