public function toggleActivation(ModuleToggleActivationEvent $event) { if (null !== ($module = ModuleQuery::create()->findPk($event->getModuleId()))) { $moduleInstance = $module->createInstance(); if (method_exists($moduleInstance, 'setContainer')) { $moduleInstance->setContainer($this->container); if ($module->getActivate() == BaseModule::IS_ACTIVATED) { $moduleInstance->deActivate($module); } else { $moduleInstance->activate($module); } } $event->setModule($module); $this->cacheClear($event->getDispatcher()); } }
/** * Get modules having current module in dependence and deactivate it if needed * * @param ModuleToggleActivationEvent $event * */ public function recursiveDeactivation(ModuleToggleActivationEvent $event) { if (null !== ($module = ModuleQuery::create()->findPk($event->getModuleId()))) { $moduleValidator = new ModuleValidator($module->getAbsoluteBaseDir()); $dependencies = $moduleValidator->getModulesDependOf(true); foreach ($dependencies as $defMod) { $submodule = ModuleQuery::create()->findOneByCode($defMod["code"]); if ($submodule && $submodule->getActivate() == BaseModule::IS_ACTIVATED) { $subevent = new ModuleToggleActivationEvent($submodule->getId()); $subevent->setRecursive(true); $event->getDispatcher()->dispatch(TheliaEvents::MODULE_TOGGLE_ACTIVATION, $subevent); } } } }