( (int)$subscriber->getId(), StatisticsUnsubscribeEntity::SOURCE_MANAGE ); } if ($subscriber && $this->linkTokens->verifyToken($subscriber, $token)) { if ($subscriberData['email'] !== Pages::DEMO_EMAIL) { $subscriber = $this->subscriberSaveController->createOrUpdate($subscriberData, $subscriber); $this->subscriberSaveController->updateCustomFields($this->filterOutEmptyMandatoryFields($subscriberData), $subscriber); $this->updateSubscriptions($subscriber, $subscriberData); } } $result = ['success' => true]; } $this->urlHelper->redirectBack($result); } private function updateSubscriptions(SubscriberEntity $subscriber, array $subscriberData): void { $segmentsIds = []; if (isset($subscriberData['segments']) && is_array($subscriberData['segments'])) { $segmentsIds = $subscriberData['segments']; } // Unsubscribe from all other segments already subscribed to // but don't change disallowed segments foreach ($subscriber->getSubscriberSegments() as $subscriberSegment) { $segment = $subscriberSegment->getSegment(); if (!$segment) { continue; } if (empty($segment->getDisplayInManageSubscriptionPage())) { continue; } if (!in_array($segment->getId(), $segmentsIds)) { $this->subscriberSegmentRepository->createOrUpdate( $subscriber, $segment, SubscriberEntity::STATUS_UNSUBSCRIBED ); } } // Store new segments for notifications $subscriberSegments = $this->subscriberSegmentRepository->findBy([ 'status' => SubscriberEntity::STATUS_SUBSCRIBED, 'subscriber' => $subscriber, ]); $currentSegmentIds = array_filter(array_map(function (SubscriberSegmentEntity $subscriberSegment): ?string { $segment = $subscriberSegment->getSegment(); return $segment ? (string)$segment->getId() : null; }, $subscriberSegments)); $newSegmentIds = array_diff($segmentsIds, $currentSegmentIds); foreach ($segmentsIds as $segmentId) { $segment = $this->segmentsRepository->findOneById($segmentId); if (!$segment) { continue; } // Allow subscribing only to allowed segments if (empty($segment->getDisplayInManageSubscriptionPage())) { continue; } $this->subscriberSegmentRepository->createOrUpdate( $subscriber, $segment, SubscriberEntity::STATUS_SUBSCRIBED ); } if ($subscriber->getStatus() === SubscriberEntity::STATUS_SUBSCRIBED && $newSegmentIds) { $newSegments = $this->segmentsRepository->findBy(['id' => $newSegmentIds]); $this->newSubscriberNotificationMailer->send($subscriber, $newSegments); $this->welcomeScheduler->scheduleSubscriberWelcomeNotification( $subscriber->getId(), $newSegmentIds ); } } private function filterOutEmptyMandatoryFields(array $subscriberData): array { $mandatory = $this->getMandatory(); foreach ($mandatory as $name) { if (!isset($subscriberData[$name])) { continue; } if (is_array($subscriberData[$name]) && count(array_filter($subscriberData[$name])) === 0) { unset($subscriberData[$name]); } if (is_string($subscriberData[$name]) && strlen(trim($subscriberData[$name])) === 0) { unset($subscriberData[$name]); } } return $subscriberData; } /** * @return string[] */ private function getMandatory(): array { $mandatory = []; $requiredCustomFields = $this->customFieldsRepository->findAll(); foreach ($requiredCustomFields as $customField) { $params = $customField->getParams(); if ( is_array($params) && isset($params['required']) && $params['required'] ) { $mandatory[] = 'cf_' . $customField->getId(); } } return $mandatory; } }
Fatal error: Uncaught Error: Class "MailPoet\Subscription\Manage" not found in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php:5388 Stack trace: #0 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2612): MailPoetGenerated\FreeCachedContainer->getManageService() #1 /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php(2640): MailPoetGenerated\FreeCachedContainer->getHooks2Service() #2 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(122): MailPoetGenerated\FreeCachedContainer->getInitializerService() #3 /htdocs/wp-content/plugins/mailpoet/vendor-prefixed/symfony/dependency-injection/Container.php(110): MailPoetVendor\Symfony\Component\DependencyInjection\Container->make('MailPoet\\Config...', 1) #4 /htdocs/wp-content/plugins/mailpoet/lib/DI/ContainerWrapper.php(39): MailPoetVendor\Symfony\Component\DependencyInjection\Container->get('MailPoet\\Config...') #5 /htdocs/wp-content/plugins/mailpoet/mailpoet_initializer.php(89): MailPoet\DI\ContainerWrapper->get('MailPoet\\Config...') #6 /htdocs/wp-content/plugins/mailpoet/mailpoet.php(194): require_once('/htdocs/wp-cont...') #7 /htdocs/wp-settings.php(526): include_once('/htdocs/wp-cont...') #8 /htdocs/wp-config.php(85): require_once('/htdocs/wp-sett...') #9 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #10 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #11 /htdocs/index.php(17): require('/htdocs/wp-blog...') #12 {main} thrown in /htdocs/wp-content/plugins/mailpoet/generated/FreeCachedContainer.php on line 5388