/** * {@inheritdoc} */ public function removeModules(Expression $expr) { $this->assertModulesLoaded(); $installInfos = $this->rootModuleFile->getInstallInfos(); $modules = $this->modules->toArray(); foreach ($this->modules->getInstalledModules() as $module) { if ($expr->evaluate($module)) { $this->rootModuleFile->removeInstallInfo($module->getName()); $this->modules->remove($module->getName()); } } if (!$installInfos) { return; } try { $this->moduleFileStorage->saveRootModuleFile($this->rootModuleFile); } catch (Exception $e) { $this->rootModuleFile->setInstallInfos($installInfos); $this->modules->replace($modules); throw $e; } }