/** * Delete a product attribute entry * * @param AttributeDeleteEvent $event */ public function delete(AttributeDeleteEvent $event) { if (null !== ($attribute = AttributeQuery::create()->findPk($event->getAttributeId()))) { $attribute->setDispatcher($event->getDispatcher())->delete(); $event->setAttribute($attribute); } }
/** * Delete a product attribute entry * * @param AttributeDeleteEvent $event * @param $eventName * @param EventDispatcherInterface $dispatcher */ public function delete(AttributeDeleteEvent $event, $eventName, EventDispatcherInterface $dispatcher) { if (null !== ($attribute = AttributeQuery::create()->findPk($event->getAttributeId()))) { $attribute->setDispatcher($dispatcher)->delete(); $event->setAttribute($attribute); } }
/** * @depends testUpdate */ public function testDelete(AttributeModel $attribute) { $event = new AttributeDeleteEvent($attribute->getId()); $event->setDispatcher($this->getMock("Symfony\\Component\\EventDispatcher\\EventDispatcherInterface")); $action = new Attribute(); $action->delete($event); $deletedAttribute = $event->getAttribute(); $this->assertInstanceOf('Thelia\\Model\\Attribute', $deletedAttribute); $this->assertTrue($deletedAttribute->isDeleted()); }