protected function getUpdateEvent($formData) { $changeEvent = new AttributeAvUpdateEvent($formData['id']); // Create and dispatch the change event $changeEvent->setLocale($formData["locale"])->setTitle($formData['title'])->setChapo($formData['chapo'])->setDescription($formData['description'])->setPostscriptum($formData['postscriptum']); return $changeEvent; }
/** * Process the attributes values (fix it in future version to integrate it in the attribute form as a collection) * * @see \Thelia\Controller\Admin\AbstractCrudController::performAdditionalUpdateAction() */ protected function performAdditionalUpdateAction($updateEvent) { $attr_values = $this->getRequest()->get('attribute_values', null); if ($attr_values !== null) { foreach ($attr_values as $id => $value) { $event = new AttributeAvUpdateEvent($id); $event->setTitle($value); $event->setLocale($this->getCurrentEditionLocale()); $this->dispatch(TheliaEvents::ATTRIBUTE_AV_UPDATE, $event); } } return null; }
/** * @param AttributeAvModel $attributeAv * @depends testCreate */ public function testUpdate(AttributeAvModel $attributeAv) { $event = new AttributeAvUpdateEvent($attributeAv->getId()); $event->setLocale($attributeAv->getLocale())->setTitle('bar')->setDescription('bar description')->setChapo('bar chapo')->setPostscriptum('bar postscriptum')->setDispatcher($this->getMock("Symfony\\Component\\EventDispatcher\\EventDispatcherInterface")); $action = new AttributeAv(); $action->update($event); $updatedAttributeAv = $event->getAttributeAv(); $this->assertInstanceOf('Thelia\\Model\\AttributeAv', $updatedAttributeAv); $this->assertEquals('bar', $updatedAttributeAv->getTitle()); $this->assertEquals('bar description', $updatedAttributeAv->getDescription()); $this->assertEquals('bar chapo', $updatedAttributeAv->getChapo()); $this->assertEquals('bar postscriptum', $updatedAttributeAv->getPostscriptum()); return $updatedAttributeAv; }