mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 08:03:49 +00:00
add form in notification thread inside entities show
This commit is contained in:
@@ -11,17 +11,27 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Notification\Templating;
|
||||
|
||||
use Chill\MainBundle\Entity\NotificationComment;
|
||||
use Chill\MainBundle\Form\NotificationCommentType;
|
||||
use Chill\MainBundle\Notification\NotificationPresence;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\RuntimeExtensionInterface;
|
||||
|
||||
class NotificationTwigExtensionRuntime implements RuntimeExtensionInterface
|
||||
{
|
||||
private FormFactoryInterface $formFactory;
|
||||
|
||||
private NotificationPresence $notificationPresence;
|
||||
|
||||
public function __construct(NotificationPresence $notificationPresence)
|
||||
private UrlGeneratorInterface $urlGenerator;
|
||||
|
||||
public function __construct(FormFactoryInterface $formFactory, NotificationPresence $notificationPresence, UrlGeneratorInterface $urlGenerator)
|
||||
{
|
||||
$this->formFactory = $formFactory;
|
||||
$this->notificationPresence = $notificationPresence;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
}
|
||||
|
||||
public function counterNotificationFor(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $options = []): string
|
||||
@@ -47,8 +57,24 @@ class NotificationTwigExtensionRuntime implements RuntimeExtensionInterface
|
||||
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,
|
||||
'notifications' => $notifications, 'appendCommentForms' => $appendCommentForms,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user