Load form templates data for template selection page from repository

[MAILPOET-2985]
This commit is contained in:
Rostislav Wolny
2020-07-01 13:44:05 +02:00
committed by Veljko V
parent 14aa0b1393
commit b4dc778230
2 changed files with 33 additions and 125 deletions

View File

@@ -23,7 +23,7 @@ class TemplateRepository {
$this->settings = $settings;
}
public function getFormEntityForTemplate($templateId): FormEntity {
public function getFormEntityForTemplate(string $templateId): FormEntity {
if (!isset($this->templates[$templateId])) {
throw UnexpectedValueException::create()
->withErrors(["Template with id $templateId doesn't exist."]);
@@ -39,6 +39,18 @@ class TemplateRepository {
return $formEntity;
}
/**
* @param string[] $templateIds
* @return FormEntity[] associative array with template ids as keys
*/
public function getFormsForTemplates(array $templateIds): array {
$result = [];
foreach ($templateIds as $templateId) {
$result[$templateId] = $this->getFormEntityForTemplate($templateId);
}
return $result;
}
private function getDefaultSuccessMessage() {
if ($this->settings->get('signup_confirmation.enabled')) {
return __('Check your inbox or spam folder to confirm your subscription.', 'mailpoet');