objectManager = $objectManagerProvider->get();
$this->remove = $remove;
$this->collector = $collector;
$this->setupFactory = $setupFactory;
}
/**
* @return PatchApplier
*/
private function getPatchApplier()
{
if (!$this->patchApplier) {
$this->patchApplier = $this->objectManager->get(PatchApplier::class);
}
return $this->patchApplier;
}
/**
* Invoke remove data routine in each specified module
*
* @param OutputInterface $output
* @param array $modules
* @return void
*/
public function uninstallData(OutputInterface $output, array $modules)
{
$uninstalls = $this->collector->collectUninstall($modules);
$setupModel = $this->setupFactory->create();
$resource = $this->objectManager->get(\Magento\Framework\Module\ModuleResource::class);
foreach ($modules as $module) {
if (isset($uninstalls[$module])) {
$output->writeln("Removing data of $module");
$uninstalls[$module]->uninstall(
$setupModel,
new ModuleContext($resource->getDbVersion($module) ?: '')
);
}
$this->getPatchApplier()->revertDataPatches($module);
}
}
/**
* Run 'composer remove' to remove code
*
* @param OutputInterface $output
* @param array $modules
* @return void
*/
public function uninstallCode(OutputInterface $output, array $modules)
{
$output->writeln('Removing code from Magento codebase:');
$packages = [];
/** @var \Magento\Framework\Module\PackageInfo $packageInfo */
$packageInfo = $this->objectManager->get(\Magento\Framework\Module\PackageInfoFactory::class)->create();
foreach ($modules as $module) {
$packages[] = $packageInfo->getPackageName($module);
}
$this->remove->remove($packages);
}
}