2024-04-20 00:04:20 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Lib\Editor;
|
|
|
|
|
|
|
|
abstract class ConditionResolver
|
|
|
|
{
|
|
|
|
|
2024-07-12 00:16:50 +02:00
|
|
|
abstract public function filterCondition(Condition $condition): bool;
|
2024-04-20 00:04:20 +02:00
|
|
|
|
|
|
|
/**
|
2024-07-14 21:44:33 +02:00
|
|
|
* @return array<int, mixed>
|
2024-04-20 00:04:20 +02:00
|
|
|
*/
|
2024-07-14 19:29:42 +02:00
|
|
|
public function makeBlocks(EditorData $data): array
|
2024-04-20 00:04:20 +02:00
|
|
|
{
|
2024-07-14 19:29:42 +02:00
|
|
|
return array_filter($data->blocks, fn ($block) => $this->filterBlock($block));
|
2024-04-20 00:04:20 +02:00
|
|
|
}
|
2024-04-23 23:48:09 +02:00
|
|
|
|
|
|
|
/**
|
2024-04-24 15:39:07 +02:00
|
|
|
* @param array<string, mixed> $block
|
2024-04-23 23:48:09 +02:00
|
|
|
*/
|
|
|
|
public function filterBlock(array $block): bool
|
|
|
|
{
|
2024-09-21 22:46:38 +02:00
|
|
|
return $this->filterCondition(Condition::factory()->withoutMagicalCreation()->from([
|
2024-07-12 18:05:11 +02:00
|
|
|
'mode' => data_get($block, 'tunes.condition.mode', 'any'),
|
|
|
|
'ifs' => data_get($block, 'tunes.condition.ifs', []),
|
|
|
|
]));
|
2024-04-23 23:48:09 +02:00
|
|
|
}
|
2024-04-20 00:04:20 +02:00
|
|
|
}
|