formFactory = $formFactory; $this->notificationPresence = $notificationPresence; $this->urlGenerator = $urlGenerator; } public function counterNotificationFor(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $options = []): string { return $environment->render( '@ChillMain/Notification/extension_counter_notifications_for.html.twig', [ 'counter' => $this->notificationPresence->countNotificationsForClassAndEntity($relatedEntityClass, $relatedEntityId), ] ); } public function countNotificationsFor(string $relatedEntityClass, int $relatedEntityId, array $options = []): array { return $this->notificationPresence->countNotificationsForClassAndEntity($relatedEntityClass, $relatedEntityId); } public function listNotificationsFor(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $options = []): string { $notifications = $this->notificationPresence->getNotificationsForClassAndEntity($relatedEntityClass, $relatedEntityId); if ([] === $notifications) { return ''; } $appendCommentForms = []; foreach ($notifications as $notification) { $appendComment = new NotificationComment(); $appendCommentForms[$notification->getId()] = $this->formFactory->create( NotificationCommentType::class, $appendComment, [ 'action' => $this->urlGenerator->generate( 'chill_main_notification_show', ['id' => $notification->getId()] ), ] )->createView(); } return $environment->render('@ChillMain/Notification/extension_list_notifications_for.html.twig', [ 'notifications' => $notifications, 'appendCommentForms' => $appendCommentForms, ]); } }