Implement NewsletterTempates::getAll() API using Doctrine

[MAILPOET-2647]
This commit is contained in:
Jan Jakeš
2020-03-05 16:09:42 +01:00
committed by Veljko V
parent a50a23c0e2
commit 29ebd113b5
4 changed files with 61 additions and 11 deletions

View File

@ -0,0 +1,26 @@
<?php
namespace MailPoet\API\JSON\ResponseBuilders;
use MailPoet\Entities\NewsletterTemplateEntity;
class NewsletterTemplatesResponseBuilder {
/**
* @param NewsletterTemplateEntity[] $newsletterTemplates
* @return mixed[]
*/
public function buildForListing(array $newsletterTemplates): array {
$data = [];
foreach ($newsletterTemplates as $template) {
$data[] = [
'id' => $template->getId(),
'categories' => $template->getCategories(),
'thumbnail' => $template->getThumbnail(),
'name' => $template->getName(),
'description' => $template->getDescription(),
'readonly' => $template->getReadonly(),
];
}
return $data;
}
}