Esempio n. 1
0
 /**
  * Parses content for URLs and tokens.
  *
  * @param EmailSendEvent $event
  * @param                $emailId
  *
  * @return mixed
  */
 protected function parseContentForUrls(EmailSendEvent $event, $emailId)
 {
     static $convertedContent = [];
     // Prevent parsing the exact same content over and over
     if (!isset($convertedContent[$event->getContentHash()])) {
         $html = $event->getContent();
         $text = $event->getPlainText();
         $contentTokens = $event->getTokens();
         list($content, $trackables) = $this->pageTrackableModel->parseContentForTrackables([$html, $text], $contentTokens, $emailId ? 'email' : null, $emailId);
         list($html, $text) = $content;
         unset($content);
         if ($html) {
             $event->setContent($html);
         }
         if ($text) {
             $event->setPlainText($text);
         }
         $convertedContent[$event->getContentHash()] = $trackables;
         // Don't need to preserve Trackable or Redirect entities in memory
         $this->em->clear('Mautic\\PageBundle\\Entity\\Redirect');
         $this->em->clear('Mautic\\PageBundle\\Entity\\Trackable');
         unset($html, $text, $trackables);
     }
     return $convertedContent[$event->getContentHash()];
 }