<?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing namespace MailPoet\Newsletter; if (!defined('ABSPATH')) exit; use MailPoet\Entities\NewsletterEntity; use MailPoet\Entities\SendingQueueEntity; use MailPoet\Entities\SubscriberEntity; use MailPoet\Router\Endpoints\ViewInBrowser as ViewInBrowserEndpoint; use MailPoet\Router\Router; use MailPoet\Subscribers\LinkTokens; class Url { /** @var LinkTokens */ private $linkTokens; public function __construct( LinkTokens $linkTokens ) { $this->linkTokens = $linkTokens; } public function getViewInBrowserUrl( ?NewsletterEntity $newsletter, ?SubscriberEntity $subscriber = null, ?SendingQueueEntity $queue = null, bool $preview = true ) { $data = $this->createUrlDataObject($newsletter, $subscriber, $queue, $preview); return Router::buildRequest( ViewInBrowserEndpoint::ENDPOINT, ViewInBrowserEndpoint::ACTION_VIEW, $data ); } public function createUrlDataObject( ?NewsletterEntity $newsletter, ?SubscriberEntity $subscriber, ?SendingQueueEntity $queue, bool $preview ) { $newsletterId = $newsletter && $newsletter->getId() ? $newsletter->getId() : 0; $newsletterHash = $newsletter && $newsletter->getHash() ? $newsletter->getHash() : 0; $sendingQueueId = $queue && $queue->getId() ? $queue->getId() : 0; return [ $newsletterId, $newsletterHash, $subscriber && $subscriber->getId() ? $subscriber->getId() : 0, $subscriber && $subscriber->getId() ? $this->linkTokens->getToken($subscriber) : 0, $sendingQueueId, (int)$preview, ]; } public function transformUrlDataObject($data) { reset($data); if (!is_int(key($data))) return $data; $transformedData = []; $transformedData['newsletter_id'] = (!empty($data[0])) ? $data[0] : false; $transformedData['newsletter_hash'] = (!empty($data[1])) ? $data[1] : false; $transformedData['subscriber_id'] = (!empty($data[2])) ? $data[2] : false; $transformedData['subscriber_token'] = (!empty($data[3])) ? $data[3] : false; $transformedData['queue_id'] = (!empty($data[4])) ? $data[4] : false; $transformedData['preview'] = (!empty($data[5])) ? $data[5] : false; return $transformedData; } }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Editor | Folder | 0755 |
|
|
Links | Folder | 0755 |
|
|
Listing | Folder | 0755 |
|
|
Options | Folder | 0755 |
|
|
Preview | Folder | 0755 |
|
|
Renderer | Folder | 0755 |
|
|
Scheduler | Folder | 0755 |
|
|
Segment | Folder | 0755 |
|
|
Sending | Folder | 0755 |
|
|
Shortcodes | Folder | 0755 |
|
|
Statistics | Folder | 0755 |
|
|
ViewInBrowser | Folder | 0755 |
|
|
ApiDataSanitizer.php | File | 1.69 KB | 0644 |
|
AutomatedLatestContent.php | File | 4.34 KB | 0644 |
|
AutomaticEmailsRepository.php | File | 2.1 KB | 0644 |
|
BlockPostQuery.php | File | 5.9 KB | 0644 |
|
NewsletterCoupon.php | File | 1.08 KB | 0644 |
|
NewsletterDeleteController.php | File | 6.85 KB | 0644 |
|
NewsletterHtmlSanitizer.php | File | 2.94 KB | 0644 |
|
NewsletterPostsRepository.php | File | 1.01 KB | 0644 |
|
NewsletterSaveController.php | File | 17.11 KB | 0644 |
|
NewsletterValidator.php | File | 4.59 KB | 0644 |
|
NewslettersRepository.php | File | 21.2 KB | 0644 |
|
Url.php | File | 2.27 KB | 0644 |
|
index.php | File | 6 B | 0644 |
|