Exemple #1
0
 /**
  * Handle point triggers for new leads (including 0 point triggers)
  *
  * @param LeadEvent $event
  */
 public function onLeadSave(LeadEvent $event)
 {
     if ($event->isNew()) {
         /** @var \Mautic\PointBundle\Model\TriggerModel */
         $model = $this->factory->getModel('point.trigger');
         $model->triggerEvents($event->getLead());
     }
 }
 public function onLeadDelete(LeadEvent $event)
 {
     /** @var \Mautic\LeadBundle\Entity\Lead $lead */
     $lead = $event->getLead();
     $serializerGroups = array("leadDetails", "userList", "publishDetails", "ipAddress");
     $payload = array('lead' => $lead);
     $types = array(LeadEvents::LEAD_POST_DELETE);
     $webhooks = $this->getEventWebooksByType($types);
     $this->webhookModel->QueueWebhooks($webhooks, $payload, $serializerGroups, true);
 }
 /**
  * Add a lead delete entry to the audit log
  *
  * @param Events\LeadEvent $event
  */
 public function onLeadDelete(Events\LeadEvent $event)
 {
     $lead = $event->getLead();
     $log = array("bundle" => "lead", "object" => "lead", "objectId" => $lead->deletedId, "action" => "delete", "details" => array('name' => $lead->getPrimaryIdentifier()), "ipAddress" => $this->factory->getIpAddressFromRequest());
     $this->factory->getModel('core.auditLog')->writeToLog($log);
 }
Exemple #4
0
 /**
  * {@inheritdoc}
  *
  * @param $action
  * @param $event
  * @param $entity
  * @param $isNew
  * @throws \Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
  */
 protected function dispatchEvent($action, &$entity, $isNew = false, Event $event = null)
 {
     if (!$entity instanceof Lead) {
         throw new MethodNotAllowedHttpException(array('Lead'), 'Entity must be of class Lead()');
     }
     switch ($action) {
         case "pre_save":
             $name = LeadEvents::LEAD_PRE_SAVE;
             break;
         case "post_save":
             $name = LeadEvents::LEAD_POST_SAVE;
             break;
         case "pre_delete":
             $name = LeadEvents::LEAD_PRE_DELETE;
             break;
         case "post_delete":
             $name = LeadEvents::LEAD_POST_DELETE;
             break;
         default:
             return null;
     }
     if ($this->dispatcher->hasListeners($name)) {
         if (empty($event)) {
             $event = new LeadEvent($entity, $isNew);
             $event->setEntityManager($this->em);
         }
         $this->dispatcher->dispatch($name, $event);
         return $event;
     } else {
         return null;
     }
 }
Exemple #5
0
 /**
  * Handle point triggers for new leads (including 0 point triggers).
  *
  * @param LeadEvent $event
  */
 public function onLeadSave(LeadEvent $event)
 {
     if ($event->isNew()) {
         $this->triggerModel->triggerEvents($event->getLead());
     }
 }
Exemple #6
0
 /**
  * Add a lead delete entry to the audit log.
  *
  * @param Events\LeadEvent $event
  */
 public function onLeadDelete(Events\LeadEvent $event)
 {
     $lead = $event->getLead();
     $log = ['bundle' => 'lead', 'object' => 'lead', 'objectId' => $lead->deletedId, 'action' => 'delete', 'details' => ['name' => $lead->getPrimaryIdentifier()], 'ipAddress' => $this->ipLookupHelper->getIpAddressFromRequest()];
     $this->auditLogModel->writeToLog($log);
 }