public function getMail()
 {
     $mail = MailInfoBridgeUploadFailed::create($this->getApplication(), $this->getReceiverMock(), $this->getEmitterMock(), $this->getMessage(), $this->getUrl(), $this->getExpiration());
     $mail->setAdapter('dailymotion');
     $mail->setReason('you\'re too fat');
     return $mail;
 }
 /**
  *
  * @param  string        $event
  * @param  Array         $params
  * @param  mixed content $object
  * @return Void
  */
 public function fire($event, $params, &$object)
 {
     $default = ['usr_id' => null, 'reason' => '', 'account_id' => null, 'base_id' => null, 'record_id' => null];
     $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');
     $reason = $dom_xml->createElement('reason');
     $account_id = $dom_xml->createElement('account_id');
     $sbas_id = $dom_xml->createElement('sbas_id');
     $record_id = $dom_xml->createElement('record_id');
     $reason->appendChild($dom_xml->createTextNode($params['reason']));
     $account_id->appendChild($dom_xml->createTextNode($params['account_id']));
     $sbas_id->appendChild($dom_xml->createTextNode($params['sbas_id']));
     $record_id->appendChild($dom_xml->createTextNode($params['record_id']));
     $root->appendChild($reason);
     $root->appendChild($account_id);
     $root->appendChild($sbas_id);
     $root->appendChild($record_id);
     $dom_xml->appendChild($root);
     $datas = $dom_xml->saveXml();
     $mailed = false;
     if ($this->shouldSendNotificationFor($params['usr_id'])) {
         $readyToSend = false;
         try {
             $user = $this->app['manipulator.user']->getRepository()->find($params['usr_id']);
             $account = Bridge_Account::load_account($this->app, $params['account_id']);
             $receiver = Receiver::fromUser($user);
             $readyToSend = true;
         } catch (\Exception $e) {
         }
         if ($readyToSend) {
             /** ADD MAIL TEST */
             $mail = MailInfoBridgeUploadFailed::create($this->app, $receiver);
             $mail->setAdapter($account->get_api()->get_connector()->get_name());
             $mail->setReason($params['reason']);
             $this->app['notification.deliverer']->deliver($mail);
             $mailed = true;
         }
     }
     $this->broker->notify($params['usr_id'], __CLASS__, $datas, $mailed);
     return;
 }
 public function onUploadFailure(BridgeUploadFailureEvent $event)
 {
     $account = $event->getElement()->get_account();
     $user = $account->get_user();
     $params = ['usr_id' => $user->getId(), 'reason' => $event->getReason(), 'account_id' => $account->get_id(), 'sbas_id' => $event->getElement()->get_record()->get_sbas_id(), 'record_id' => $event->getElement()->get_record()->get_record_id()];
     $datas = json_encode($params);
     $mailed = false;
     if ($this->shouldSendNotificationFor($user, 'eventsmanager_notify_bridgeuploadfail')) {
         try {
             $receiver = Receiver::fromUser($user);
             $readyToSend = true;
         } catch (\Exception $e) {
             $readyToSend = false;
         }
         if ($readyToSend) {
             $mail = MailInfoBridgeUploadFailed::create($this->app, $receiver);
             $mail->setAdapter($account->get_api()->get_connector()->get_name());
             $mail->setReason($params['reason']);
             $this->deliver($mail);
             $mailed = true;
         }
     }
     $this->app['events-manager']->notify($params['usr_id'], 'eventsmanager_notify_bridgeuploadfail', $datas, $mailed);
 }