Skip to content

Commit 8844ff2

Browse files
committed
Adjusted code samples for Notifications
1 parent f4d2373 commit 8844ff2

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

code_samples/back_office/notifications/src/Notification/ListRenderer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Ibexa\Core\Notification\Renderer\TypedNotificationRendererInterface;
1010
use Symfony\Component\HttpFoundation\RequestStack;
1111
use Symfony\Component\Routing\RouterInterface;
12+
use Symfony\Contracts\Translation\TranslatorInterface;
1213
use Twig\Environment;
1314

1415
class ListRenderer implements NotificationRenderer, TypedNotificationRendererInterface
@@ -19,11 +20,14 @@ class ListRenderer implements NotificationRenderer, TypedNotificationRendererInt
1920

2021
protected RequestStack $requestStack;
2122

22-
public function __construct(Environment $twig, RouterInterface $router, RequestStack $requestStack)
23+
protected TranslatorInterface $translator;
24+
25+
public function __construct(Environment $twig, RouterInterface $router, RequestStack $requestStack, TranslatorInterface $translator)
2326
{
2427
$this->twig = $twig;
2528
$this->router = $router;
2629
$this->requestStack = $requestStack;
30+
$this->translator = $translator;
2731
}
2832

2933
public function render(Notification $notification): string

code_samples/back_office/notifications/src/Notification/MyRenderer.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Ibexa\Core\Notification\Renderer\NotificationRenderer;
99
use Ibexa\Core\Notification\Renderer\TypedNotificationRendererInterface;
1010
use Symfony\Component\Routing\RouterInterface;
11+
use Symfony\Contracts\Translation\TranslatorInterface;
1112
use Twig\Environment;
1213

1314
class MyRenderer implements NotificationRenderer, TypedNotificationRendererInterface
@@ -16,17 +17,20 @@ class MyRenderer implements NotificationRenderer, TypedNotificationRendererInter
1617

1718
protected RouterInterface $router;
1819

19-
public function __construct(Environment $twig, RouterInterface $router)
20+
protected TranslatorInterface $translator;
21+
22+
public function __construct(Environment $twig, RouterInterface $router, TranslatorInterface $translator)
2023
{
2124
$this->twig = $twig;
2225
$this->router = $router;
26+
$this->translator = $translator;
2327
}
2428

2529
public function render(Notification $notification): string
2630
{
2731
return $this->twig->render('@ibexadesign/notification.html.twig', [
2832
'notification' => $notification,
29-
'template_to_extend' => $templateToExtend,
33+
'template_to_extend' => '@ibexadesign/account/notifications/list_item.html.twig',
3034
]);
3135
}
3236

@@ -39,8 +43,6 @@ public function generateUrl(Notification $notification): ?string
3943
return null;
4044
}
4145

42-
}
43-
4446
public function getTypeLabel(): string
4547
{
4648
return /** @Desc("Workflow stage changed") */

code_samples/notifications/Src/Query/search.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
declare(strict_types=1);
44

5-
use Ibexa\Contracts\Core\Repository\Values\NotificationQuery;
5+
use Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion\DateCreated;
6+
use Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion\Status;
7+
use Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion\Type;
8+
use Ibexa\Contracts\Core\Repository\Values\Notification\Query\NotificationQuery;
69

7-
$repository = $this->getRepository();
8-
$notificationService = $repository->getNotificationService();
10+
/** @var \Ibexa\Contracts\Core\Repository\NotificationService $notificationService */
911
$query = new NotificationQuery([], 0, 25);
1012

1113
$query->addCriterion(new Type('Workflow:Review'));

0 commit comments

Comments
 (0)