mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-18 11:48:06 +00:00
WIP: render entities
This commit is contained in:
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Audit;
|
||||
|
||||
use Chill\MainBundle\Audit\Exception\ConvertSubjectException;
|
||||
use Chill\MainBundle\Audit\Exception\DisplaySubjectException;
|
||||
|
||||
final readonly class SubjectConverterManager implements SubjectConverterManagerInterface
|
||||
{
|
||||
@@ -20,6 +21,11 @@ final readonly class SubjectConverterManager implements SubjectConverterManagerI
|
||||
* @var iterable<SubjectConverterInterface>
|
||||
*/
|
||||
private iterable $converters,
|
||||
|
||||
/**
|
||||
* @var iterable<SubjectDisplayerInterface>
|
||||
*/
|
||||
private iterable $displayers,
|
||||
) {}
|
||||
|
||||
public function getSubjectsForEntity(mixed $subject, bool $includeAssociated = false): SubjectBag
|
||||
@@ -36,4 +42,15 @@ final readonly class SubjectConverterManager implements SubjectConverterManagerI
|
||||
|
||||
throw new ConvertSubjectException($subject);
|
||||
}
|
||||
|
||||
public function display(Subject $subject, array $options = []): string
|
||||
{
|
||||
foreach ($this->displayers as $displayer) {
|
||||
if ($displayer->supportsDisplay($subject, $options = [])) {
|
||||
return $displayer->display($subject, $options = []);
|
||||
}
|
||||
}
|
||||
|
||||
throw new DisplaySubjectException($subject->asArray());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user