Add form template ability to transform to form entity

[MAILPOET-2810]
This commit is contained in:
Rostislav Wolny
2020-08-05 15:34:06 +02:00
committed by Veljko V
parent 9155b8d95a
commit 04e431dae5
2 changed files with 11 additions and 5 deletions

View File

@ -2,6 +2,8 @@
namespace MailPoet\Form\Templates;
use MailPoet\Entities\FormEntity;
abstract class Template {
abstract public function getName(): string;
@ -91,4 +93,12 @@ abstract class Template {
}
EOL;
}
public function toFormEntity(): FormEntity {
$formEntity = new FormEntity($this->getName());
$formEntity->setBody($this->getBody());
$formEntity->setSettings($this->getSettings());
$formEntity->setStyles($this->getStyles());
return $formEntity;
}
}

View File

@ -25,11 +25,7 @@ class TemplateRepository {
}
/** @var Template $template */
$template = new $this->templates[$templateId]();
$formEntity = new FormEntity($template->getName());
$formEntity->setBody($template->getBody());
$formEntity->setSettings($template->getSettings());
$formEntity->setStyles($template->getStyles());
return $formEntity;
return $template->toFormEntity();
}
/**