Handle saving and loading list page. Add support for showInManageSubscriptionPage checkbox input

MAILPOET-4669
This commit is contained in:
Oluwaseun Olorunsola
2022-11-02 13:15:23 +01:00
committed by Aschepikov
parent 31c2915075
commit 48181994d8
3 changed files with 8 additions and 2 deletions

View File

@ -34,6 +34,7 @@ class SegmentsResponseBuilder {
'deleted_at' => ($deletedAt = $segment->getDeletedAt()) ? $deletedAt->format(self::DATE_FORMAT) : null,
'average_engagement_score' => $segment->getAverageEngagementScore(),
'filters_connect' => $segment->getFiltersConnectOperator(),
'showInManageSubscriptionPage' => $segment->getDisplayInManageSubscriptionPage(),
];
}

View File

@ -33,8 +33,9 @@ class SegmentSaveController {
$id = isset($data['id']) ? (int)$data['id'] : null;
$name = $data['name'] ?? '';
$description = $data['description'] ?? '';
$displayInManageSubPage = $data['showInManageSubscriptionPage'] ?? null;
return $this->segmentsRepository->createOrUpdate($name, $description, SegmentEntity::TYPE_DEFAULT, [], $id);
return $this->segmentsRepository->createOrUpdate($name, $description, SegmentEntity::TYPE_DEFAULT, [], $id, $displayInManageSubPage);
}
/**

View File

@ -133,8 +133,10 @@ class SegmentsRepository extends Repository {
string $description = '',
string $type = SegmentEntity::TYPE_DEFAULT,
array $filtersData = [],
?int $id = null
?int $id = null,
?int $displayInManageSubscriptionPage = 1
): SegmentEntity {
$displayInManageSubPage = $type === SegmentEntity::TYPE_DEFAULT ? $displayInManageSubscriptionPage ?? 1 : 0;
if ($id) {
$segment = $this->findOneById($id);
if (!$segment instanceof SegmentEntity) {
@ -145,9 +147,11 @@ class SegmentsRepository extends Repository {
$segment->setName($name);
}
$segment->setDescription($description);
$segment->setDisplayInManageSubscriptionPage($displayInManageSubPage);
} else {
$this->verifyNameIsUnique($name, $id);
$segment = new SegmentEntity($name, $type, $description);
$segment->setDisplayInManageSubscriptionPage($displayInManageSubPage);
$this->persist($segment);
}