*/ class CommentRender implements ChillEntityRenderInterface { use BoxUtilsChillEntityRenderTrait; /** * @var EngineInterface */ private $engine; private UserRepositoryInterface $userRepository; public function __construct( UserRepositoryInterface $userRepository, EngineInterface $engine ) { $this->userRepository = $userRepository; $this->engine = $engine; } public function renderBox($entity, array $options): string { // default options $options = array_merge([ 'user' => [], 'disable_markdown' => false, 'limit_lines' => null, 'metadata' => true, ], $options); if (null !== $entity->getUserId()) { $user = $this->userRepository->find($entity->getUserId()); } return $this->engine ->render( '@ChillMain/Entity/CommentEmbeddable.html.twig', [ 'opening_box' => $this->getDefaultOpeningBox('comment-embeddable'), 'closing_box' => $this->getDefaultClosingBox(), 'user' => $user ?? null, 'comment' => $entity, 'options' => $options, ] ); } public function renderString($entity, array $options): string { return $entity->getComment(); } public function supports($entity, array $options): bool { return $entity instanceof CommentEmbeddable; } }