Ejemplo n.º 1
0
 /**
  * Toggle category visibility. No form used here
  *
  * @param ActionEvent $event
  */
 public function toggleVisibility(CategoryToggleVisibilityEvent $event)
 {
     $category = $event->getCategory();
     $category->setDispatcher($event->getDispatcher())->setVisible($category->getVisible() ? false : true)->save();
     $event->setCategory($category);
 }
Ejemplo n.º 2
0
 public function testToggleVisibility()
 {
     $category = $this->getRandomCategory();
     $expectedVisibility = !$category->getVisible();
     $event = new CategoryToggleVisibilityEvent($category);
     $event->setDispatcher($this->getDispatcher());
     $action = new Category();
     $action->toggleVisibility($event);
     $updatedCategory = $event->getCategory();
     $this->assertInstanceOf('Thelia\\Model\\Category', $updatedCategory);
     $this->assertEquals($expectedVisibility, $updatedCategory->getVisible());
 }
Ejemplo n.º 3
0
 /**
  * Toggle category visibility. No form used here
  *
  * @param CategoryToggleVisibilityEvent $event
  * @param $eventName
  * @param EventDispatcherInterface $dispatcher
  */
 public function toggleVisibility(CategoryToggleVisibilityEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     $category = $event->getCategory();
     $category->setDispatcher($dispatcher)->setVisible($category->getVisible() ? false : true)->save();
     $event->setCategory($category);
 }