public function onFinish(ValidationEvent $event)
 {
     $params = ['from' => $event->getParticipant()->getUser()->getId(), 'to' => $event->getBasket()->getValidation()->getInitiator()->getId(), 'ssel_id' => $event->getBasket()->getId()];
     $datas = json_encode($params);
     $mailed = false;
     if ($this->shouldSendNotificationFor($event->getBasket()->getValidation()->getInitiator(), 'eventsmanager_notify_validationdone')) {
         $readyToSend = false;
         try {
             $user_from = $event->getParticipant()->getUser();
             $user_to = $event->getBasket()->getValidation()->getInitiator();
             $basket = $event->getBasket();
             $title = $basket->getName();
             $receiver = Receiver::fromUser($user_to);
             $emitter = Emitter::fromUser($user_from);
             $readyToSend = true;
         } catch (\Exception $e) {
         }
         if ($readyToSend) {
             $mail = MailInfoValidationDone::create($this->app, $receiver, $emitter);
             $mail->setButtonUrl($event->getUrl());
             $mail->setTitle($title);
             $mail->setUser($user_from);
             $this->deliver($mail);
             $mailed = true;
         }
     }
     return $this->app['events-manager']->notify($params['to'], 'eventsmanager_notify_validationdone', $datas, $mailed);
 }
 public function getMail()
 {
     $mail = MailInfoValidationDone::create($this->getApplication(), $this->getReceiverMock(), $this->getEmitterMock(), $this->getMessage(), $this->getUrl(), $this->getExpiration());
     $user = $this->createUserMock();
     $user->expects($this->any())->method('getDisplayName')->will($this->returnValue('JeanPhil'));
     $mail->setTitle('Hulk hogan');
     $mail->setUser($user);
     return $mail;
 }
 /**
  *
  * @param  Array         $event
  * @param  Array         $params
  * @param  mixed content $object
  * @return boolean
  */
 public function fire($event, $params, &$object)
 {
     $default = ['from' => '', 'to' => '', 'ssel_id' => ''];
     $params = array_merge($default, $params);
     $dom_xml = new DOMDocument('1.0', 'UTF-8');
     $dom_xml->preserveWhiteSpace = false;
     $dom_xml->formatOutput = true;
     $root = $dom_xml->createElement('datas');
     $from = $dom_xml->createElement('from');
     $to = $dom_xml->createElement('to');
     $ssel_id = $dom_xml->createElement('ssel_id');
     $from->appendChild($dom_xml->createTextNode($params['from']));
     $to->appendChild($dom_xml->createTextNode($params['to']));
     $ssel_id->appendChild($dom_xml->createTextNode($params['ssel_id']));
     $root->appendChild($from);
     $root->appendChild($to);
     $root->appendChild($ssel_id);
     $dom_xml->appendChild($root);
     $datas = $dom_xml->saveXml();
     $mailed = false;
     if ($this->shouldSendNotificationFor($params['to'])) {
         $readyToSend = false;
         try {
             $user_from = $this->app['manipulator.user']->getRepository()->find($params['from']);
             $user_to = $this->app['manipulator.user']->getRepository()->find($params['to']);
             $basket = $this->app['EM']->getRepository('Phraseanet:Basket')->find($params['ssel_id']);
             $title = $basket->getName();
             $receiver = Receiver::fromUser($user_to);
             $emitter = Emitter::fromUser($user_from);
             $readyToSend = true;
         } catch (\Exception $e) {
         }
         if ($readyToSend) {
             $mail = MailInfoValidationDone::create($this->app, $receiver, $emitter);
             $mail->setButtonUrl($params['url']);
             $mail->setTitle($title);
             $mail->setUser($user_from);
             $this->app['notification.deliverer']->deliver($mail);
             $mailed = true;
         }
     }
     return $this->broker->notify($params['to'], __CLASS__, $datas, $mailed);
 }