Refactor dynamic segments get endpoint to doctrine
[MAILPOET-3177]
This commit is contained in:
committed by
Veljko V
parent
d42752fa99
commit
bd63ae508f
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace MailPoet\API\JSON\ResponseBuilders;
|
||||
|
||||
use MailPoet\Entities\DynamicSegmentFilterEntity;
|
||||
use MailPoet\Entities\SegmentEntity;
|
||||
use MailPoet\Entities\SubscriberEntity;
|
||||
use MailPoet\Segments\SegmentSubscribersRepository;
|
||||
@@ -29,6 +30,16 @@ class DynamicSegmentsResponseBuilder {
|
||||
$this->wp = $wp;
|
||||
}
|
||||
|
||||
public function build(SegmentEntity $segmentEntity) {
|
||||
$data = $this->segmentsResponseBuilder->build($segmentEntity);
|
||||
// So far we allow dynamic segments to have only one filter
|
||||
$filter = $segmentEntity->getDynamicFilters()->first();
|
||||
if (!$filter instanceof DynamicSegmentFilterEntity) {
|
||||
return $data;
|
||||
}
|
||||
return array_merge($data, $filter->getFilterData() ?? []);
|
||||
}
|
||||
|
||||
public function buildForListing(array $segments): array {
|
||||
$data = [];
|
||||
foreach ($segments as $segment) {
|
||||
|
Reference in New Issue
Block a user