Example #1
0
 /**
  * @param       $event
  * @param       $leadId
  * @param array $source
  * @param null  $emailId
  *
  * @return array
  */
 private function generateTokensFromContent($event, $leadId, $source = [], $emailId = null)
 {
     $content = $event->getContent();
     $clickthrough = [];
     if ($event instanceof PageDisplayEvent || $event instanceof EmailSendEvent && $event->shouldAppendClickthrough()) {
         $clickthrough = ['source' => $source];
         if ($leadId !== null) {
             $clickthrough['lead'] = $leadId;
         }
         if (!empty($emailId)) {
             $clickthrough['email'] = $emailId;
         }
     }
     return $this->tokenHelper->findAssetTokens($content, $clickthrough);
 }
Example #2
0
 /**
  * PreParse the twitter message and replace placeholders with values.
  *
  * @param $tweet
  * @param $lead
  *
  * @return mixed
  */
 protected function parseTweetText($tweet, $lead)
 {
     $tweetHandle = $lead['twitter'];
     $tokens = ['{twitter_handle}' => strpos($tweetHandle, '@') !== false ? $tweetHandle : "@{$tweetHandle}"];
     $tokens = array_merge($tokens, TokenHelper::findLeadTokens($tweet, $lead), $this->pageTokenHelper->findPageTokens($tweet, $this->clickthrough), $this->assetTokenHelper->findAssetTokens($tweet, $this->clickthrough));
     list($tweet, $trackables) = $this->trackableModel->parseContentForTrackables($tweet, $tokens, 'social_twitter', -1);
     /**
      * @var string $token
      * @var Trackable $trackable
      */
     foreach ($trackables as $token => $trackable) {
         $tokens[$token] = $this->trackableModel->generateTrackableUrl($trackable, $this->clickthrough);
     }
     return str_replace(array_keys($tokens), array_values($tokens), $tweet);
 }
Example #3
0
 /**
  * @param TokenReplacementEvent $event
  */
 public function onTokenReplacement(TokenReplacementEvent $event)
 {
     /** @var Lead $lead */
     $lead = $event->getLead();
     $content = $event->getContent();
     $clickthrough = $event->getClickthrough();
     if ($content) {
         $tokens = array_merge(TokenHelper::findLeadTokens($content, $lead->getProfileFields()), $this->pageTokenHelper->findPageTokens($content, $clickthrough), $this->assetTokenHelper->findAssetTokens($content, $clickthrough));
         list($content, $trackables) = $this->trackableModel->parseContentForTrackables($content, $tokens, 'sms', $clickthrough['channel'][1]);
         /**
          * @var string
          * @var Trackable $trackable
          */
         foreach ($trackables as $token => $trackable) {
             $tokens[$token] = $this->trackableModel->generateTrackableUrl($trackable, $clickthrough, true);
         }
         $content = str_replace(array_keys($tokens), array_values($tokens), $content);
         $event->setContent($content);
     }
 }