Refactor getting segments from form body to form entity
[MAILPOET-3297]
This commit is contained in:
committed by
Veljko V
parent
36a7cc0b25
commit
af574f7e1b
@ -211,18 +211,10 @@ class Forms extends APIEndpoint {
|
||||
// or if it's selected by the admin
|
||||
$formEntity = new FormEntity($name);
|
||||
$formEntity->setBody($body);
|
||||
$listSelectionBlocks = $formEntity->getBlocksByType(FormEntity::SEGMENT_SELECTION_BLOCK_TYPE);
|
||||
$listSelection = [];
|
||||
foreach ($listSelectionBlocks as $listSelectionBlock) {
|
||||
$listSelection = array_unique(
|
||||
array_merge(
|
||||
$listSelection, array_column($listSelectionBlock['params']['values'] ?? [], 'id')
|
||||
)
|
||||
);
|
||||
}
|
||||
$listSelection = $formEntity->getSegmentBlocksSegmentIds();
|
||||
|
||||
// check list selection
|
||||
if (count($listSelectionBlocks)) {
|
||||
if (count($listSelection)) {
|
||||
$settings['segments_selected_by'] = 'user';
|
||||
$settings['segments'] = $listSelection;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user