Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Ibexa\Core\Notification\Renderer\TypedNotificationRendererInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment;

class ListRenderer implements NotificationRenderer, TypedNotificationRendererInterface
Expand All @@ -19,11 +20,14 @@ class ListRenderer implements NotificationRenderer, TypedNotificationRendererInt

protected RequestStack $requestStack;

public function __construct(Environment $twig, RouterInterface $router, RequestStack $requestStack)
protected TranslatorInterface $translator;

public function __construct(Environment $twig, RouterInterface $router, RequestStack $requestStack, TranslatorInterface $translator)
{
$this->twig = $twig;
$this->router = $router;
$this->requestStack = $requestStack;
$this->translator = $translator;
}

public function render(Notification $notification): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Ibexa\Core\Notification\Renderer\NotificationRenderer;
use Ibexa\Core\Notification\Renderer\TypedNotificationRendererInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment;

class MyRenderer implements NotificationRenderer, TypedNotificationRendererInterface
Expand All @@ -16,17 +17,20 @@ class MyRenderer implements NotificationRenderer, TypedNotificationRendererInter

protected RouterInterface $router;

public function __construct(Environment $twig, RouterInterface $router)
protected TranslatorInterface $translator;

public function __construct(Environment $twig, RouterInterface $router, TranslatorInterface $translator)
{
$this->twig = $twig;
$this->router = $router;
$this->translator = $translator;
}

public function render(Notification $notification): string
{
return $this->twig->render('@ibexadesign/notification.html.twig', [
'notification' => $notification,
'template_to_extend' => $templateToExtend,
'template_to_extend' => '@ibexadesign/account/notifications/list_item.html.twig',
]);
}

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

}

public function getTypeLabel(): string
{
return /** @Desc("Workflow stage changed") */
Expand Down
8 changes: 5 additions & 3 deletions code_samples/notifications/Src/Query/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

declare(strict_types=1);

use Ibexa\Contracts\Core\Repository\Values\NotificationQuery;
use Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion\DateCreated;
use Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion\Status;
use Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion\Type;
use Ibexa\Contracts\Core\Repository\Values\Notification\Query\NotificationQuery;

$repository = $this->getRepository();
$notificationService = $repository->getNotificationService();
/** @var \Ibexa\Contracts\Core\Repository\NotificationService $notificationService */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the repository usage, I think it's not recommended and injecting the service directly is the way to go for some time now.

$query = new NotificationQuery([], 0, 25);

$query->addCriterion(new Type('Workflow:Review'));
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
"ibexa/tree-builder": "~4.6.x-dev",
"ibexa/discounts": "~4.6.x-dev",
"ibexa/discounts-codes": "~4.6.x-dev",
"ibexa/product-catalog-symbol-attribute": "~4.6.x-dev"
"ibexa/product-catalog-symbol-attribute": "~4.6.x-dev",
"ibexa/messenger": "~4.6.x-dev"
},
"scripts": {
"fix-cs": "php-cs-fixer fix --config=.php-cs-fixer.php -v --show-progress=dots",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ The `DateCreated` Search Criterion searches for notifications based on the date

### PHP

```php hl_lines="14-15 17"
```php hl_lines="16-17 19"
[[= include_file('code_samples/notifications/Src/Query/search.php') =]]
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ The `Status` Search Criterion searches for notifications based on notification s

### PHP

```php hl_lines="12"
```php hl_lines="14"
[[= include_file('code_samples/notifications/Src/Query/search.php') =]]
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ The `Type` Search Criterion searches for notifications by their types.

### PHP

```php hl_lines="11"
```php hl_lines="13"
[[= include_file('code_samples/notifications/Src/Query/search.php') =]]
```
Loading