public function getMail()
 {
     $mail = MailInfoOrderCancelled::create($this->getApp(), $this->getReceiverMock(), $this->getEmitterMock(), $this->getMessage());
     $user = $this->createUserMock();
     $user->expects($this->any())->method('getDisplayName')->will($this->returnValue('JeanPhil'));
     $mail->setDeliverer($user);
     $mail->setQuantity(42);
     return $mail;
 }
Beispiel #2
0
 public function onDeny(OrderDeliveryEvent $event)
 {
     $params = ['from' => $event->getAdmin()->getId(), 'to' => $event->getOrder()->getUser()->getId(), 'n' => $event->getQuantity()];
     $datas = json_encode($params);
     $mailed = false;
     if ($this->shouldSendNotificationFor($event->getOrder()->getUser(), 'eventsmanager_notify_ordernotdelivered')) {
         $user_from = $event->getAdmin();
         $user_to = $event->getOrder()->getUser();
         $receiver = Receiver::fromUser($user_to);
         $emitter = Emitter::fromUser($user_from);
         $mail = MailInfoOrderCancelled::create($this->app, $receiver, $emitter);
         $mail->setQuantity($params['n']);
         $mail->setDeliverer($user_from);
         $this->app['notification.deliverer']->deliver($mail);
         $mailed = true;
     }
     return $this->app['events-manager']->notify($params['to'], 'eventsmanager_notify_ordernotdelivered', $datas, $mailed);
 }
 public function fire($event, $params, &$object)
 {
     $default = ['from' => '', 'to' => '', 'n' => ''];
     $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');
     $n = $dom_xml->createElement('n');
     $from->appendChild($dom_xml->createTextNode($params['from']));
     $to->appendChild($dom_xml->createTextNode($params['to']));
     $n->appendChild($dom_xml->createTextNode($params['n']));
     $root->appendChild($from);
     $root->appendChild($to);
     $root->appendChild($n);
     $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']);
             $receiver = Receiver::fromUser($user_to);
             $emitter = Emitter::fromUser($user_from);
             $readyToSend = true;
         } catch (\Exception $e) {
         }
         if ($readyToSend) {
             $mail = MailInfoOrderCancelled::create($this->app, $receiver, $emitter);
             $mail->setQuantity($params['n']);
             $mail->setDeliverer($user_from);
             $this->app['notification.deliverer']->deliver($mail);
             $mailed = true;
         }
     }
     return $this->broker->notify($params['to'], __CLASS__, $datas, $mailed);
 }