Exemple #1
0
 public function testCreate()
 {
     $event = new MessageCreateEvent();
     $event->setMessageName('test')->setLocale('en_US')->setTitle('test title')->setSecured(0)->setDispatcher($this->dispatcher);
     $action = new Message();
     $action->create($event);
     $createdMessage = $event->getMessage();
     $this->assertInstanceOf('Thelia\\Model\\Message', $createdMessage);
     $this->assertFalse($createdMessage->isNew());
     $this->assertEquals('test', $createdMessage->getName());
     $this->assertEquals('en_US', $createdMessage->getLocale());
     $this->assertEquals('test title', $createdMessage->getTitle());
     $this->assertEquals(0, $createdMessage->getSecured());
     return $createdMessage;
 }
Exemple #2
0
 protected function getCreationEvent($formData)
 {
     $createEvent = new MessageCreateEvent();
     $createEvent->setMessageName($formData['name'])->setLocale($formData["locale"])->setTitle($formData['title'])->setSecured($formData['secured'] ? true : false);
     return $createEvent;
 }
Exemple #3
0
 /**
  * Create a new messageuration entry
  *
  * @param \Thelia\Core\Event\Message\MessageCreateEvent $event
  */
 public function create(MessageCreateEvent $event)
 {
     $message = new MessageModel();
     $message->setDispatcher($event->getDispatcher())->setName($event->getMessageName())->setLocale($event->getLocale())->setTitle($event->getTitle())->setSecured($event->getSecured())->save();
     $event->setMessage($message);
 }