CustomFieldsResponseBuilder.php
11 months ago
DynamicSegmentsResponseBuilder.php
2 months ago
FormsResponseBuilder.php
11 months ago
NewsletterTemplatesResponseBuilder.php
11 months ago
NewslettersResponseBuilder.php
3 weeks ago
ScheduledTaskSubscriberResponseBuilder.php
3 years ago
SegmentsResponseBuilder.php
2 months ago
SendingQueuesResponseBuilder.php
2 months ago
SubscribersResponseBuilder.php
2 weeks ago
index.php
3 years ago
CustomFieldsResponseBuilder.php
34 lines
| 1 | <?php // phpcs:ignore SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing |
| 2 | |
| 3 | namespace MailPoet\API\JSON\ResponseBuilders; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Entities\CustomFieldEntity; |
| 9 | |
| 10 | class CustomFieldsResponseBuilder { |
| 11 | /** |
| 12 | * @param CustomFieldEntity[] $customFields |
| 13 | * @return array |
| 14 | */ |
| 15 | public function buildBatch(array $customFields) { |
| 16 | return array_map([$this, 'build'], $customFields); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * @param CustomFieldEntity $customField |
| 21 | * @return array |
| 22 | */ |
| 23 | public function build(CustomFieldEntity $customField) { |
| 24 | return [ |
| 25 | 'id' => $customField->getId(), |
| 26 | 'name' => $customField->getName(), |
| 27 | 'type' => $customField->getType(), |
| 28 | 'params' => $customField->getParams(), |
| 29 | 'created_at' => ($createdAt = $customField->getCreatedAt()) ? $createdAt->format('Y-m-d H:i:s') : null, |
| 30 | 'updated_at' => ($updatedAt = $customField->getUpdatedAt()) ? $updatedAt->format('Y-m-d H:i:s') : null, |
| 31 | ]; |
| 32 | } |
| 33 | } |
| 34 |