Exemplo n.º 1
0
 public function createRecipientSource(RecipientSource $recipientSourceData)
 {
     $recipientSource = new Dummy($recipientSourceData->getDummyMinCount(), $recipientSourceData->getDummyMaxCount());
     /** @var EventDispatcherInterface $eventDispatcher */
     $eventDispatcher = $GLOBALS['container']['event-dispatcher'];
     $event = new CreateRecipientSourceEvent($recipientSourceData, $recipientSource);
     $eventDispatcher->dispatch(CoreEvents::CREATE_RECIPIENT_SOURCE, $event);
     return $event->getRecipientSource();
 }
Exemplo n.º 2
0
 /**
  * Create the recipient source.
  *
  * @param RecipientSource $recipientSourceData
  *
  * @return \Avisota\RecipientSource\RecipientSourceInterface
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 public function createRecipientSource(RecipientSource $recipientSourceData)
 {
     global $container;
     $clean = $recipientSourceData->getUnionClean();
     $recipientSourceIds = $recipientSourceData->getUnionRecipientSources();
     $unionRecipientSource = new Union();
     $unionRecipientSource->setClean($clean);
     foreach ($recipientSourceIds as $recipientSourceId) {
         $recipientSource = $container[sprintf('avisota.recipientSource.%s', $recipientSourceId)];
         $unionRecipientSource->addRecipientSource($recipientSource);
     }
     /** @var EventDispatcherInterface $eventDispatcher */
     $eventDispatcher = $GLOBALS['container']['event-dispatcher'];
     $event = new CreateRecipientSourceEvent($recipientSourceData, $unionRecipientSource);
     $eventDispatcher->dispatch(CoreEvents::CREATE_RECIPIENT_SOURCE, $event);
     return $event->getRecipientSource();
 }
 public function createRecipientSource(RecipientSource $recipientSourceEntity)
 {
     $recipientSource = new RecipientsRecipientSourceSalutations();
     if ($recipientSourceEntity->getFilter()) {
         if ($recipientSourceEntity->getFilterByMailingLists()) {
             $recipientSource->setFilteredMailingLists($recipientSourceEntity->getMailingLists()->toArray());
         }
         if ($recipientSourceEntity->getRecipientsUsePropertyFilter()) {
             $recipientSource->setFilteredProperties($recipientSourceEntity->getRecipientsPropertyFilter());
         }
     }
     /** @var EventDispatcherInterface $eventDispatcher */
     $eventDispatcher = $GLOBALS['container']['event-dispatcher'];
     if ($recipientSourceEntity->getRecipientsManageSubscriptionPage()) {
         $getPageDetailsEvent = new GetPageDetailsEvent($recipientSourceEntity->getRecipientsManageSubscriptionPage());
         $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_GET_PAGE_DETAILS, $getPageDetailsEvent);
         $generateFrontendUrlEvent = new GenerateFrontendUrlEvent($getPageDetailsEvent->getPageDetails());
         $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_GENERATE_FRONTEND_URL, $generateFrontendUrlEvent);
         $url = $generateFrontendUrlEvent->getUrl();
         $url .= (strpos($url, '?') !== false ? '&' : '?') . 'avisota_subscription_email=##email##';
         if (!preg_match('~^\\w+:~', $url)) {
             $environment = \Environment::getInstance();
             $url = rtrim($environment->base, '/') . '/' . ltrim($url, '/');
         }
         $recipientSource->setManageSubscriptionUrlPattern($url);
     }
     if ($recipientSourceEntity->getRecipientsUnsubscribePage()) {
         $getPageDetailsEvent = new GetPageDetailsEvent($recipientSourceEntity->getRecipientsUnsubscribePage());
         $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_GET_PAGE_DETAILS, $getPageDetailsEvent);
         $generateFrontendUrlEvent = new GenerateFrontendUrlEvent($getPageDetailsEvent->getPageDetails());
         $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_GENERATE_FRONTEND_URL, $generateFrontendUrlEvent);
         $url = $generateFrontendUrlEvent->getUrl();
         $url .= (strpos($url, '?') !== false ? '&' : '?') . 'avisota_subscription_email=##email##';
         if (!preg_match('~^\\w+:~', $url)) {
             $environment = \Environment::getInstance();
             $url = rtrim($environment->base, '/') . '/' . ltrim($url, '/');
         }
         $recipientSource->setUnsubscribeUrlPattern($url);
     }
     $event = new CreateRecipientSourceEvent($recipientSourceEntity, $recipientSource);
     $eventDispatcher->dispatch(CoreEvents::CREATE_RECIPIENT_SOURCE, $event);
     return $event->getRecipientSource();
 }
Exemplo n.º 4
0
 public function createRecipientSource(RecipientSource $recipientSourceData)
 {
     $file = \Compat::resolveFile($recipientSourceData->getCsvFileSrc());
     $columns = array();
     $delimiter = $recipientSourceData->getCsvFileDelimiter();
     $enclosure = $recipientSourceData->getCsvFileEnclosure();
     foreach ($recipientSourceData->getCsvColumnAssignment() as $item) {
         $columns[$item['column'] - 1] = $item['field'];
     }
     switch ($delimiter) {
         case 'semicolon':
             $delimiter = ';';
             break;
         case 'space':
             $delimiter = ' ';
             break;
         case 'tabulator':
             $delimiter = "\t";
             break;
         case 'linebreak':
             $delimiter = "\n";
             break;
         default:
             $delimiter = ',';
     }
     switch ($enclosure) {
         case 'single':
             $enclosure = "'";
             break;
         default:
             $enclosure = '"';
     }
     $recipientSource = new CSVFile(TL_ROOT . DIRECTORY_SEPARATOR . $file, $columns, $delimiter, $enclosure);
     /** @var EventDispatcherInterface $eventDispatcher */
     $eventDispatcher = $GLOBALS['container']['event-dispatcher'];
     $event = new CreateRecipientSourceEvent($recipientSourceData, $recipientSource);
     $eventDispatcher->dispatch(CoreEvents::CREATE_RECIPIENT_SOURCE, $event);
     return $event->getRecipientSource();
 }
 /**
  * @param RecipientSource           $entity
  * @param RecipientsRecipientSource $recipientSource
  * @SuppressWarnings(PHPMD.LongVariable)
  */
 protected function parseRecipientsUnsubscribePage(RecipientSource $entity, RecipientsRecipientSource &$recipientSource)
 {
     if (!$entity->getRecipientsUnsubscribePage()) {
         return;
     }
     global $container;
     /** @var EventDispatcherInterface $eventDispatcher */
     $eventDispatcher = $container['event-dispatcher'];
     $getPageDetailsEvent = new GetPageDetailsEvent($entity->getRecipientsUnsubscribePage());
     $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_GET_PAGE_DETAILS, $getPageDetailsEvent);
     $generateFrontendUrlEvent = new GenerateFrontendUrlEvent($getPageDetailsEvent->getPageDetails());
     $eventDispatcher->dispatch(ContaoEvents::CONTROLLER_GENERATE_FRONTEND_URL, $generateFrontendUrlEvent);
     $url = $generateFrontendUrlEvent->getUrl();
     $url .= (strpos($url, '?') !== false ? '&' : '?') . 'avisota_subscription_email=##email##';
     if (!preg_match('~^\\w+:~', $url)) {
         $url = rtrim(\Environment::get('base'), '/') . '/' . ltrim($url, '/');
     }
     $recipientSource->setUnsubscribeUrlPattern($url);
     $event = new CreateRecipientSourceEvent($entity, $recipientSource);
     $eventDispatcher->dispatch(CoreEvents::CREATE_RECIPIENT_SOURCE, $event);
     $recipientSource = $event->getRecipientSource();
 }
Exemplo n.º 6
0
 /**
  * Create the recipient source.
  *
  * @param RecipientSource $recipientSource The recipient source.
  *
  * @return mixed
  *
  * @SuppressWarnings(PHPMD.LongVariable)
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 public function createRecipientSource(RecipientSource $recipientSource)
 {
     $recipientSourceFactoryClass = new \ReflectionClass($GLOBALS['AVISOTA_RECIPIENT_SOURCE'][$recipientSource->getType()]);
     /** @var RecipientSourceFactoryInterface $recipientSourceFactory */
     $recipientSourceFactory = $recipientSourceFactoryClass->newInstance();
     return $recipientSourceFactory->createRecipientSource($recipientSource);
 }