public function _editReport(ServiceEvent $e)
 {
     $this->clearEvent();
     if ($e->getIsError()) {
         return $this->OnError($e);
     }
     $data = [];
     $entity = false;
     $id = $e->getEntityId();
     $em = $this->getEntityManager();
     try {
         $r = $em->getRepository($e->getEntityClass());
         if ($r) {
             $entity = $r->findOneBy(['id' => $id]);
             if ($entity) {
                 $data['action'] = $e->getDescription();
                 $data['message'] = $e->getMessage();
                 foreach (['\\Event\\Entity\\ReportEvent', '\\Event\\Entity\\AccountEvent'] as $_event) {
                     $event = new $_event();
                     $this->dispatch($entity, $event, $data);
                 }
             }
         }
     } catch (\Exception $e) {
         // fail silently
     }
 }
 /**
  *
  * @param ServiceEvent $e        	
  */
 public function postPostClientData(ServiceEvent $e)
 {
     $this->clearEvent();
     if ($e->getIsError()) {
         return $this->OnError($e);
     }
     $data = [];
     $entity = false;
     $id = $e->getEntityId();
     $em = $this->getEntityManager();
     try {
         $r = $em->getRepository($e->getEntityClass());
         if ($r) {
             $entity = $r->findOneBy(['id' => $id]);
             if ($entity) {
                 $data['action'] = $e->getDescription();
                 $data['message'] = $e->getMessage();
                 $data['response'] = $e->getResult();
                 $data['service'] = $e->getParam('service', 'subject_upload');
                 $data['clientId'] = $e->getParam('clientId', 0);
                 $data['outcome'] = $e->getOutcome();
                 foreach (['\\Event\\Entity\\TenStreetApiEvent' => true, '\\Event\\Entity\\LeadEvent' => false] as $_event => $_update) {
                     $event = new $_event();
                     $this->dispatch($entity, $event, $data, $_update);
                 }
             }
         }
     } catch (\Exception $e) {
         // fail silently
     }
 }
 public function postSendMail(ServiceEvent $e)
 {
     $this->clearEvent();
     if ($e->getIsError()) {
         return $this->OnError($e);
     }
     $data = [];
     $entity = false;
     $id = $e->getEntityId();
     $em = $this->getEntityManager();
     try {
         $r = $em->getRepository($e->getEntityClass());
         if ($r) {
             $entity = $r->findOneBy(['id' => $id]);
             if ($entity) {
                 $data['action'] = $e->getDescription();
                 $data['message'] = $e->getMessage();
                 $data['response'] = $e->getResult();
                 $data['addressTo'] = $e->getParam('addressTo', 'Unknown Recipient');
                 $data['outcome'] = $e->getOutcome();
                 foreach (['\\Event\\Entity\\EmailApiEvent' => true, '\\Event\\Entity\\LeadEvent' => false] as $_event => $_update) {
                     $event = new $_event();
                     $this->dispatch($entity, $event, $data, $_update);
                 }
             }
         }
     } catch (\Exception $e) {
         // fail silently
     }
 }
 public function _editAttribute(ServiceEvent $e)
 {
     $this->clearEvent();
     if ($e->getIsError()) {
         return $this->OnError($e);
     }
     $data = [];
     $entity = false;
     $id = $e->getEntityId();
     $em = $this->getEntityManager();
     try {
         $r = $em->getRepository($e->getEntityClass());
         if ($r) {
             $entity = $r->findOneBy(['id' => $id]);
             if ($entity) {
                 $data['action'] = $e->getDescription();
                 $data['message'] = $e->getParam('message', $e->getMessage());
                 $this->dispatch($entity, null, $data);
             }
         }
     } catch (\Exception $e) {
         // fail silently
     }
 }
 /**
  * On Error Listener
  *
  * @param ServiceEvent $e        	
  *
  * @return boolean
  */
 public function OnError(ServiceEvent $e)
 {
     $data = [];
     $data['action'] = $e->getDescription();
     $data['message'] = $e->getMessage();
     $data['trace'] = $e->getResult();
     return $this->dispatch(null, new ErrorEvent(), $data);
 }