0¤APÈAÖA bA‚%AA°w&A°®"AÀ~&AÀ~&A ãA~&A(A€­"AèØ A`s Ap²'A0¤A ë&A•A¨²'AàA¨æA8ãA³'AAˆbA ãAÖA bAˆ®"AAy&A°®"Aˆ~&A(A8_"A'¡•ˆßUþP?˜Z•ˆßUÿÿÿÿÿÿÿÿI˜Z•ˆßUðÿÿÿÿÿÿÿÿIr •ˆßU ¼ˆàpû—•ˆßUÿÿÿÿÿÿÿÿdL`•ˆßUPÀÀ]Æy•ˆßUÀP¹@|•ˆßUÿÿÿÿÿÿÿÿÐ<ye•ˆßU`Ðÿÿÿÿ"‘•ˆßU P=a•ˆßU`Pu@|•ˆßUÿÿÿÿÿÿÿÿð<GŒ•ˆßUð@ÿÿÿÿ+b•ˆßU`ÿÿÿÿÿÿÿÿ>R†•ˆßUÿÿÿÿÀ;û—•ˆßUÿÿÿÿÿÿÿÿdL`•ˆßUP ]Æy•ˆßUP¹@|•ˆßUÿÿÿÿÿÿÿÿ<GŒ•ˆßU@ÿÿÿÿ+Aj•ˆßU0 Dë‚•ˆßU0Pt"‘•ˆßU€ (=5ƒ•ˆßUPA@|•ˆßUÿÿÿÿÿÿÿÿ0<z•ˆßU0`2ë‚•ˆßUÀptž•ˆßUÿÿÿÿÿÿÿÿÿÿÿÿ<íl•ˆßU ÿÿÿÿÿÿÿÿ>r •ˆßU ¼ˆp0#p@|•ˆßUÿÿÿÿÿÿÿÿP#<ye•ˆßUpPÿÿÿÿ#"‘•ˆßU 0@$=a•ˆßUpP$u@|•ˆßUÿÿÿÿÿÿÿÿp$<GŒ•ˆßUp@ÿÿÿÿ$+b•ˆßUpÿÿÿÿÿÿÿÿ%>r •ˆßU ¼ˆ H(pû€•ˆßU`P(Bû€•ˆßUP`(B@|•ˆßUÿÿÿÿÿÿÿÿ€(<ye•ˆßU€€ÿÿÿÿ(R†•ˆßUÿÿÿÿ X);|`•ˆßUP  )Q¤m•ˆßU ÿÿÿÿ°)G­x•ˆßU°P)t@|•ˆßUÿÿÿÿÿÿÿÿÀ)<ye•ˆßUÀÿÿÿÿ)"‘•ˆßU `+=a•ˆßUP+u@|•ˆßUÿÿÿÿÿÿÿÿà+<GŒ•ˆßUà ÿÿÿÿ++׊•ˆßU h,pë‚•ˆßU P,tž•ˆßUÿÿÿÿÿÿÿÿÿÿÿÿ,<b•ˆßUÿÿÿÿÿÿÿÿ.>Aj•ˆßUÐx1D l•ˆßUÐà 3G׊•ˆßU€Ð€4p@|•ˆßUÿÿÿÿÿÿÿÿ 4<W•ˆßU °4H­x•ˆßUP4tž•ˆßUÿÿÿÿÿÿÿÿÿÿÿÿ1<íl•ˆßUÿÿÿÿÿÿÿÿ4>,\•ˆßU@ÿÿÿÿÿÿÿÿÿÿÿÿ7>ðó×\9`ô×\9°Æ'A°Æ'APåAØØA€X A€X APåAÐ#Aø#AHÐ'A•AˆÐ'ApgÕ\9`É'A`É'AØØA}&A}&AÏAÏAPåAØØA@hA@hA¨gÕ\90µAP&AAàÃAàÃAæAC7UüàA¨æA8ãAÈÈ%AÀ¸A ¿A•A8¿'AàA¨æA8ãAèæ Aà& A•Ap¿'AàAãA8ãAèæ A :ºˆßUÀ¸Aȵ'A•A°¿'AàAId && $existingStepId === $step->getId()) { continue; } $this->storeNewsletterOption( $newsletter, NewsletterOptionFieldEntity::NAME_AUTOMATION_ID, (string)$automationId ); $this->storeNewsletterOption( $newsletter, NewsletterOptionFieldEntity::NAME_AUTOMATION_STEP_ID, $step->getId() ); $this->newslettersRepository->flush(); } } } /** * Stores a newsletter option * * @param NewsletterEntity $newsletter The newsletter entity * @param string $optionName The name of the option * @param string|null $optionValue The value of the option * @return void */ private function storeNewsletterOption(NewsletterEntity $newsletter, string $optionName, ?string $optionValue = null): void { if (!$optionValue || !$this->newsletterOptionsRepository || !$this->newsletterOptionFieldsRepository) { return; } $existingOption = $newsletter->getOption($optionName); if ($existingOption && $existingOption->getValue() === $optionValue) { return; // Skip if option already exists with the same value } $field = $this->newsletterOptionFieldsRepository->findOneBy([ 'name' => $optionName, 'newsletterType' => $newsletter->getType(), ]); if (!$field) { return; } // If option exists but with different value, update it if ($existingOption) { $existingOption->setValue($optionValue); return; } // Otherwise create a new option $option = new NewsletterOptionEntity($newsletter, $field); $option->setValue($optionValue); $this->newsletterOptionsRepository->persist($option); $newsletter->getOptions()->add($option); } /** * Get the default sender name from settings */ private function getDefaultSenderName(): string { return $this->settings->get('sender.name', ''); } /** * Get the default sender address from settings */ private function getDefaultSenderAddress(): string { return $this->settings->get('sender.address', ''); } /** * Load a template from a file * * @param string $templateName The name of the template file (without .json extension) * @return array|null The template body or null if the template doesn't exist */ public function loadTemplate(string $templateName): ?array { $templatePath = $this->getTemplatePath($templateName); if (!file_exists($templatePath)) { throw new NotFoundException('Template not found: ' . $templateName); } return $this->fetchEmailTemplate($templatePath); } /** * Get the path to a template file * * @param string $templateName The name of the template file (without .json extension) * @return string The full path to the template file */ protected function getTemplatePath(string $templateName): string { $sanitizedTemplateName = $this->wp->sanitizeFileName($templateName); return $this->getTemplatesDirectory() . '/' . $sanitizedTemplateName . '.json'; } /** * Fetch email template from a file * * @param string $templatePath The path to the template file * @return array|null The template body or null if the template couldn't be loaded */ private function fetchEmailTemplate(string $templatePath): ?array { $templateString = file_get_contents($templatePath); if ($templateString === false) { return null; } $templateArr = json_decode((string)$templateString, true); if (!is_array($templateArr) || !isset($templateArr['body'])) { return null; } return $templateArr['body']; } /** * Set the templates directory * * @param string|null $directory The directory where templates are stored * @return self */ public function setTemplatesDirectory(?string $directory): self { $this->templatesDirectory = $directory; return $this; } /** * Get the templates directory * * @return string The directory where templates are stored */ public function getTemplatesDirectory(): string { return $this->templatesDirectory ?: Env::$libPath . '/Automation/Integrations/MailPoet/Templates/EmailTemplates'; } }