Implement NewsletterTempates::get() API using Doctrine

[MAILPOET-2647]
This commit is contained in:
Jan Jakeš
2020-03-05 16:38:31 +01:00
committed by Veljko V
parent 29ebd113b5
commit 4d110bbb68
2 changed files with 25 additions and 7 deletions

View File

@ -5,6 +5,23 @@ namespace MailPoet\API\JSON\ResponseBuilders;
use MailPoet\Entities\NewsletterTemplateEntity;
class NewsletterTemplatesResponseBuilder {
const DATE_FORMAT = 'Y-m-d H:i:s';
public function build(NewsletterTemplateEntity $template): array {
return [
'id' => $template->getId(),
'categories' => $template->getCategories(),
'thumbnail' => $template->getThumbnail(),
'name' => $template->getName(),
'description' => $template->getDescription(),
'readonly' => $template->getReadonly(),
'body' => $template->getBody(),
'created_at' => $template->getCreatedAt()->format(self::DATE_FORMAT),
'updated_at' => $template->getUpdatedAt()->format(self::DATE_FORMAT),
'newsletter_id' => ($newsletter = $template->getNewsletter()) ? $newsletter->getId() : null,
];
}
/**
* @param NewsletterTemplateEntity[] $newsletterTemplates
* @return mixed[]