Exemple #1
0
 /**
  * @param CampaignExecutionEvent $event
  */
 public function onCampaignTriggerAction(CampaignExecutionEvent $event)
 {
     $eventConfig = $event->getConfig();
     $lead = $event->getLead();
     $slot = $this->session->get('dwc.slot_name.lead.' . $lead->getId());
     $dwc = $this->dynamicContentModel->getRepository()->getEntity($eventConfig['dynamicContent']);
     if ($dwc instanceof DynamicContent) {
         // Use translation if available
         list($ignore, $dwc) = $this->dynamicContentModel->getTranslatedEntity($dwc, $lead);
         if ($slot) {
             $this->dynamicContentModel->setSlotContentForLead($dwc, $lead, $slot);
         }
         $this->dynamicContentModel->createStatEntry($dwc, $lead, $slot);
         $tokenEvent = new TokenReplacementEvent($dwc->getContent(), $lead, ['slot' => $slot, 'dynamic_content_id' => $dwc->getId()]);
         $this->factory->getDispatcher()->dispatch(DynamicContentEvents::TOKEN_REPLACEMENT, $tokenEvent);
         $content = $tokenEvent->getContent();
         $event->stopPropagation();
         $result = $event->setResult($content);
         $event->setChannel('dynamicContent', $dwc->getId());
         return $result;
     }
 }