コード例 #1
0
ファイル: Module.php プロジェクト: alex63530/thelia
 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());
     }
 }
コード例 #2
0
ファイル: Module.php プロジェクト: margery/thelia
 /**
  * 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);
             }
         }
     }
 }