/** * Toggle Brand visibility * * @param BrandToggleVisibilityEvent $event * @param string $eventName * @param EventDispatcherInterface $dispatcher * @throws \Exception * @throws \Propel\Runtime\Exception\PropelException */ public function toggleVisibility(BrandToggleVisibilityEvent $event, $eventName, EventDispatcherInterface $dispatcher) { $brand = $event->getBrand(); $brand->setDispatcher($dispatcher)->setVisible(!$brand->getVisible())->save(); $event->setBrand($brand); }
public function testBrandToggleVisibility() { $brand = $this->getRandomBrand(); $visibility = $brand->getVisible(); $event = new BrandToggleVisibilityEvent($brand); $event->setDispatcher($this->dispatcher); $brandAction = new Brand($this->getContainer()); $brandAction->toggleVisibility($event); $updatedBrand = $event->getBrand(); $this->assertInstanceOf('Thelia\\Model\\Brand', $updatedBrand); $this->assertEquals(!$visibility, $updatedBrand->getVisible()); }
/** * Toggle Brand visibility * * @param BrandToggleVisibilityEvent $event */ public function toggleVisibility(BrandToggleVisibilityEvent $event) { $brand = $event->getBrand(); $brand->setDispatcher($event->getDispatcher())->setVisible(!$brand->getVisible())->save(); $event->setBrand($brand); }