mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add form in notification thread inside entities show
This commit is contained in:
parent
7f41f14959
commit
59cdf07c7e
@ -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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,10 @@
|
||||
{% include 'ChillMainBundle:Notification:_list_item.html.twig' with {
|
||||
'full_content': true,
|
||||
'fold_item': true,
|
||||
'action_button': true,
|
||||
'with_folded_comments': false
|
||||
'action_button': false,
|
||||
'with_folded_comments': true,
|
||||
'appendCommentForm': appendCommentForms[notification.id],
|
||||
'editedCommentForm': null,
|
||||
} %}{#
|
||||
#}
|
||||
{% endfor %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user