-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathMyRenderer.php
More file actions
53 lines (42 loc) · 1.46 KB
/
Copy pathMyRenderer.php
File metadata and controls
53 lines (42 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
declare(strict_types=1);
namespace App\Notification;
use Ibexa\Contracts\Core\Repository\Values\Notification\Notification;
use Ibexa\Core\Notification\Renderer\NotificationRenderer;
use Ibexa\Core\Notification\Renderer\TypedNotificationRendererInterface;
use Symfony\Component\Routing\RouterInterface;
use Twig\Environment;
class MyRenderer implements NotificationRenderer, TypedNotificationRendererInterface
{
protected Environment $twig;
protected RouterInterface $router;
public function __construct(Environment $twig, RouterInterface $router)
{
$this->twig = $twig;
$this->router = $router;
}
public function render(Notification $notification): string
{
return $this->twig->render('@ibexadesign/notification.html.twig', [
'notification' => $notification,
'template_to_extend' => $templateToExtend,
]);
}
public function generateUrl(Notification $notification): ?string
{
if (array_key_exists('content_id', $notification->data)) {
return $this->router->generate('ibexa.content.view', ['contentId' => $notification->data['content_id']]);
}
return null;
}
}
public function getTypeLabel(): string
{
return /** @Desc("Workflow stage changed") */
$this->translator->trans(
'workflow.notification.stage_change.label',
[],
'ibexa_workflow'
);
}
}