示例#1
0
 /**
  * @params ModuleHookModel $hook
  * @depends testCreate
  */
 public function testToggleActivation(ModuleHookModel $moduleHook)
 {
     $activated = $moduleHook->getActive();
     $event = new ModuleHookToggleActivationEvent($moduleHook);
     $event->setDispatcher($this->dispatcher);
     $this->action->toggleModuleHookActivation($event);
     $updatedModuleHook = $event->getModuleHook();
     $this->assertEquals(!$activated, $updatedModuleHook->getActive());
     return $updatedModuleHook;
 }
示例#2
0
 public function toggleModuleHookActivation(ModuleHookToggleActivationEvent $event)
 {
     if (null !== ($moduleHook = $event->getModuleHook())) {
         if ($moduleHook->getModuleActive()) {
             $moduleHook->setActive(!$moduleHook->getActive());
             $moduleHook->save();
         } else {
             throw new \LogicException(Translator::getInstance()->trans("The module has to be activated."));
         }
     }
     $this->cacheClear($event->getDispatcher());
     return $event;
 }