"newsletter", orphanRemoval=true) * @var ArrayCollection */ private $newsletterSegments; /** * @ORM\OneToMany(targetEntity="MailPoet\Entities\NewsletterOptionEntity", mappedBy="newsletter", orphanRemoval=true) * @var ArrayCollection */ private $options; /** * @ORM\OneToMany(targetEntity="MailPoet\Entities\SendingQueueEntity", mappedBy="newsletter") * @var ArrayCollection */ private $queues; /** * @ORM\OneToOne(targetEntity="MailPoet\Entities\WpPostEntity") * @ORM\JoinColumn(name="wp_post_id", referencedColumnName="ID", nullable=true) * @var WpPostEntity|null */ private $wpPost; public function __construct() { $this->children = new ArrayCollection(); $this->newsletterSegments = new ArrayCollection(); $this->options = new ArrayCollection(); $this->queues = new ArrayCollection(); } /** * @deprecated This is here only for backward compatibility with custom shortcodes https://kb.mailpoet.com/article/160-create-a-custom-shortcode * This can be removed after 2021-08-01 */ public function __get($key) { $getterName = 'get' . Helpers::underscoreToCamelCase($key, $capitaliseFirstChar = true); $callable = [$this, $getterName]; if (is_callable($callable)) { return call_user_func($callable); } } public function __clone() { // reset ID $this->id = null; $this->newsletterSegments = new ArrayCollection(); $this->children = new ArrayCollection(); $this->options = new ArrayCollection(); $this->queues = new ArrayCollection(); } /** * @return string|null */ public function getHash() { return $this->hash; } /** * @param string|null $hash */ public function setHash($hash) { $this->hash = $hash; } /** * @return string */ public function getSubject() { return $this->subject; } /** * @param string $subject */ public function setSubject($subject) { $this->subject = $subject; } /** * @return string */ public function getType() { return $this->type; } /** * @param string $type */ public function setType($type) { $this->type = $type; } /** * @return string */ public function getSenderAddress() { return $this->senderAddress; } /** * @param string $senderAddress */ public function setSenderAddress($senderAddress) { $this->senderAddress = $senderAddress; } /** * @return string */ public function getSenderName() { return $this->senderName; } /** * @param string $senderName */ public function setSenderName($senderName) { $this->senderName = $senderName; } /** * @return string */ public function getStatus() { return $this->status; } /** * @param string $status */ public function setStatus($status) { $this->status = $status; // activate/deactivate unfinished tasks $newTaskStatus = null; $typesWithActivation = [self::TYPE_NOTIFICATION, self::TYPE_WELCOME, self::TYPE_AUTOMATIC]; if (($status === self::STATUS_DRAFT) && in_array($this->type, $typesWithActivation)) { $newTaskStatus = ScheduledTaskEntity::STATUS_PAUSED; } if (($status === self::STATUS_ACTIVE) && in_array($this->type, $typesWithActivation)) { $newTaskStatus = ScheduledTaskEntity::STATUS_SCHEDULED; } if (!$newTaskStatus) return; $queues = $this->getUnfinishedQueues(); foreach ($queues as $queue) { /** @var SendingQueueEntity $queue */ $task = $queue->getTask(); if ($task === null) continue; $scheduled = new Carbon($task->getScheduledAt()); if ($scheduled < (new Carbon())->subDays(30)) continue; if (($status === self::STATUS_DRAFT) && ($task->getStatus() !== ScheduledTaskEntity::STATUS_SCHEDULED)) continue; if (($status === self::STATUS_ACTIVE) && ($task->getStatus() !== ScheduledTaskEntity::STATUS_PAUSED)) continue; $task->setStatus($newTaskStatus); } } /** * @return string */ public function getReplyToAddress() { return $this->replyToAddress; } /** * @param string $replyToAddress */ public function setReplyToAddress($replyToAddress) { $this->replyToAddress = $replyToAddress; } /** * @return string */ public function getReplyToName() { return $this->replyToName; } /** * @param string $replyToName */ public function setReplyToName($replyToName) { $this->replyToName = $replyToName; } /** * @return string */ public function getPreheader() { return $this->preheader; } /** * @param string $preheader */ public function setPreheader($preheader) { $this->preheader = $preheader; } /** * @return array|null */ public function getBody() { return $this->body; } /** * @param array|null $body */ public function setBody($body) { $this->body = $body; } /** * @return DateTimeInterface|null */ public function getSentAt() { return $this->sentAt; } /** * @param DateTimeInterface|null $sentAt */ public function setSentAt($sentAt) { $this->sentAt = $sentAt; } /** * @return string|null */ public function getUnsubscribeToken() { return $this->unsubscribeToken; } /** * @return string */ public function getGaCampaign() { return $this->gaCampaign; } /** * @param string $gaCampaign */ public function setGaCampaign($gaCampaign) { $this->gaCampaign = $gaCampaign; } /** * @param string|null $unsubscribeToken */ public function setUnsubscribeToken($unsubscribeToken) { $this->unsubscribeToken = $unsubscribeToken; } /** * @return NewsletterEntity|null */ public function getParent() { $this->safelyLoadToOneAssociation('parent'); return $this->parent; } /** * @param NewsletterEntity|null $parent */ public function setParent($parent) { $this->parent = $parent; } /** * @return ArrayCollection */ public function getChildren() { return $this->children; } /** * @return ArrayCollection */ public function getNewsletterSegments() { return $this->newsletterSegments; } /** * @return int[] */ public function getSegmentIds() { return array_filter($this->newsletterSegments->map(function(NewsletterSegmentEntity $newsletterSegment = null) { if (!$newsletterSegment) return null; $segment = $newsletterSegment->getSegment(); return $segment ? (int)$segment->getId() : null; })->toArray()); } /** * @return ArrayCollection */ public function getOptions() { return $this->options; } public function getOption(string $name): ?NewsletterOptionEntity { $option = $this->options->filter(function (NewsletterOptionEntity $option = null) use ($name): bool { if (!$option) return false; return ($field = $option->getOptionField()) ? $field->getName() === $name : false; })->first(); return $option ?: null; } /** * @return array Associative array of newsletter option values with option names as keys */ public function getOptionsAsArray(): array { $optionsArray = []; foreach ($this->options as $option) { $name = $option->getName(); if (!$name) { continue; } $optionsArray[$name] = $option->getValue(); } return $optionsArray; } public function getOptionValue(string $name) { $option = $this->getOption($name); return $option ? $option->getValue() : null; } public function getFilterSegmentId(): ?int { $optionValue = $this->getOptionValue(NewsletterOptionFieldEntity::NAME_FILTER_SEGMENT_ID); if ($optionValue) { return (int)$optionValue; } $parentNewsletter = $this->getParent(); if ($parentNewsletter instanceof NewsletterEntity && $this->getId() !== $parentNewsletter->getId()) { return $parentNewsletter->getFilterSegmentId(); } return null; } /** * @return ArrayCollection */ public function getQueues() { return $this->queues; } public function getLatestQueue(): ?SendingQueueEntity { $criteria = new Criteria(); $criteria->orderBy(['id' => Criteria::DESC]); $criteria->setMaxResults(1); return $this->queues->matching($criteria)->first() ?: null; } public function getLastUpdatedQueue(): ?SendingQueueEntity { $criteria = new Criteria(); $criteria->orderBy(['updatedAt' => Criteria::DESC]); $criteria->setMaxResults(1); return $this->queues->matching($criteria)->first() ?: null; } /** * @return Collection */ private function getUnfinishedQueues(): Collection { $criteria = new Criteria(); $expr = Criteria::expr(); $criteria->where($expr->neq('countToProcess', 0)); return $this->queues->matching($criteria); } public function getGlobalStyle(string $category, string $style): ?string { $body = $this->getBody(); if ($body === null) { return null; } return $body['globalStyles'][$category][$style] ?? null; } public function getProcessedAt(): ?DateTimeInterface { $processedAt = null; $queue = $this->getLatestQueue(); if ($queue instanceof SendingQueueEntity) { $task = $queue->getTask(); if ($task instanceof ScheduledTaskEntity) { $processedAt = $task->getProcessedAt(); } } return $processedAt; } public function getContent(): string { $content = $this->getBody()['content'] ?? ''; return json_encode($content) ?: ''; } /** * Only some types of newsletters can be set as sent. Some others are just active or draft. */ public function canBeSetSent(): bool { return in_array($this->getType(), [self::TYPE_NOTIFICATION_HISTORY, self::TYPE_STANDARD], true); } public function getWpPost(): ?WpPostEntity { $this->safelyLoadToOneAssociation('wpPost'); return $this->wpPost; } public function setWpPost(?WpPostEntity $wpPostEntity): void { $this->wpPost = $wpPostEntity; } public function getWpPostId(): ?int { $wpPost = $this->wpPost; return $wpPost ? $wpPost->getId() : null; } public function getCampaignName(): ?string { $wpPost = $this->getWpPost(); if (!$wpPost) { return null; } return $wpPost->getPostTitle(); } /** * Used for cases when we present newsletter by name. * Newsletters created via legacy editor have only subjects. */ public function getCampaignNameOrSubject(): string { $campaignName = $this->getCampaignName(); return $campaignName ?: $this->getSubject(); } }
Fatal error: Uncaught ReflectionException: Class "MailPoet\Entities\NewsletterEntity" does not exist in /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/doctrine/persistence/src/Persistence/Mapping/RuntimeReflectionService.php:45 Stack trace: #0 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/doctrine/persistence/src/Persistence/Mapping/RuntimeReflectionService.php(45): ReflectionClass->__construct('MailPoet\\Entiti...') #1 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php(277): MailPoetVendor\Doctrine\Persistence\Mapping\RuntimeReflectionService->getClass('MailPoet\\Entiti...') #2 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php(494): MailPoetVendor\Doctrine\ORM\Mapping\ClassMetadataInfo->wakeupReflection(Object(MailPoetVendor\Doctrine\Persistence\Mapping\RuntimeReflectionService)) #3 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/doctrine/persistence/src/Persistence/Mapping/AbstractClassMetadataFactory.php(106): MailPoetVendor\Doctrine\ORM\Mapping\ClassMetadataFactory->wakeupReflection(Object(MailPoetVendor\Doctrine\ORM\Mapping\ClassMetadata), Object(MailPoetVendor\Doctrine\Persistence\Mapping\RuntimeReflectionService)) #4 /htdocs/wp-content/plugins/mailpoet/lib/Doctrine/TablePrefixMetadataFactory.php(44): MailPoetVendor\Doctrine\Persistence\Mapping\AbstractClassMetadataFactory->getMetadataFor('MailPoet\\Entiti...') #5 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(143): MailPoet\Doctrine\TablePrefixMetadataFactory->getMetadataFor('MailPoet\\Entiti...') #6 /htdocs/wp-content/plugins/mailpoet/lib/Doctrine/Repository.php(36): MailPoetVendor\Doctrine\ORM\EntityManager->getClassMetadata('MailPoet\\Entiti...') #7 /htdocs/wp-content/plugins/mailpoet/lib/Newsletter/NewslettersRepository.php(36): MailPoet\Doctrine\Repository->__construct(Object(MailPoetVendor\Doctrine\ORM\EntityManager)) #8 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(3931): MailPoet\Newsletter\NewslettersRepository->__construct(Object(MailPoetVendor\Doctrine\ORM\EntityManager)) #9 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(4091): MailPoetGenerated\FreeCachedContainer->getNewslettersRepositoryService() #10 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(4808): MailPoetGenerated\FreeCachedContainer->getWelcomeSchedulerService() #11 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2673): MailPoetGenerated\FreeCachedContainer->getWPService() #12 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2578): MailPoetGenerated\FreeCachedContainer->getPopulatorService() #13 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2640): MailPoetGenerated\FreeCachedContainer->getActivatorService() #14 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(122): MailPoetGenerated\FreeCachedContainer->getInitializerService() #15 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(110): MailPoetVendor\Symfony\Component\DependencyInjection\Container->make('MailPoet\\Config...', 1) #16 /htdocs/wp-content/plugins/mailpoet/lib/DI/ContainerWrapper.php(39): MailPoetVendor\Symfony\Component\DependencyInjection\Container->get('MailPoet\\Config...') #17 /htdocs/wp-content/plugins/mailpoet/mailpoet_initializer.php(89): MailPoet\DI\ContainerWrapper->get('MailPoet\\Config...') #18 /htdocs/wp-content/plugins/mailpoet/mailpoet.php(194): require_once('/htdocs/wp-cont...') #19 /htdocs/wp-settings.php(526): include_once('/htdocs/wp-cont...') #20 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #21 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #22 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #23 /htdocs/index.php(17): require('/htdocs/wp-blog...') #24 {main} thrown in /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/doctrine/persistence/src/Persistence/Mapping/RuntimeReflectionService.php on line 45