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
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array<string, mixed> $content
|
|
|
|
* @return array<string, mixed>
|
|
|
|
*/
|
2024-04-23 23:48:09 +02:00
|
|
|
public function makeBlocks(array $content): array
|
2024-04-20 00:04:20 +02:00
|
|
|
{
|
2024-04-20 00:29:32 +02:00
|
|
|
return array_filter(data_get($content, '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-07-12 00:16:50 +02:00
|
|
|
return $this->filterCondition(Condition::fromBlock($block));
|
2024-04-23 23:48:09 +02:00
|
|
|
}
|
2024-04-20 00:04:20 +02:00
|
|
|
}
|