-
Notifications
You must be signed in to change notification settings - Fork 82
IBX-9060: Document revamped notifications #2797
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
a03ba22
ca0e86d
676c74b
b52a111
f24589f
0333d4f
dcdd3a3
2b3047a
6501726
64d3e75
bcfdb17
d5db454
57e3b07
5d85f8c
6f5fcd9
b2645e2
bb3a648
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Notification; | ||
|
||
use Ibexa\Contracts\Core\Repository\Values\Notification\Notification; | ||
use Ibexa\Core\Notification\Renderer\NotificationRenderer; | ||
use Symfony\Component\HttpFoundation\RequestStack; | ||
use Symfony\Component\Routing\RouterInterface; | ||
use Twig\Environment; | ||
|
||
class ListRenderer implements NotificationRenderer | ||
dabrt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
dabrt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
{ | ||
protected Environment $twig; | ||
|
||
protected RouterInterface $router; | ||
|
||
protected RequestStack $requestStack; | ||
|
||
public function __construct(Environment $twig, RouterInterface $router, RequestStack $requestStack) | ||
{ | ||
$this->twig = $twig; | ||
$this->router = $router; | ||
$this->requestStack = $requestStack; | ||
} | ||
|
||
public function render(Notification $notification): string | ||
{ | ||
$templateToExtend = '@ibexadesign/account/notifications/list_item.html.twig'; | ||
$currentRequest = $this->requestStack->getCurrentRequest(); | ||
if ($currentRequest && $currentRequest->attributes->getBoolean('render_all')) { | ||
$templateToExtend = '@ibexadesign/account/notifications/list_item_all.html.twig'; | ||
} | ||
|
||
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; | ||
} | ||
dabrt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Ibexa\Contracts\Core\Repository\Values\NotificationQuery; | ||
|
||
$repository = $this->getRepository(); | ||
$notificationService = $repository->getNotificationService(); | ||
$query = new NotificationQuery([], 0, 25); | ||
|
||
$query->addCriterion(new Type('Workflow:Review')); | ||
Check failure on line 11 in code_samples/notifications/Src/Query/search.php
|
||
$query->addCriterion(new Status(['unread'])); | ||
Check failure on line 12 in code_samples/notifications/Src/Query/search.php
|
||
|
||
$from = new \DateTimeImmutable('-7 days'); | ||
$to = new \DateTimeImmutable(); | ||
|
||
$query->addCriterion(new DateCreated($from, $to)); | ||
|
||
$notificationList = $notificationService->findNotifications($query); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
Check warning on line 1 in docs/search/criteria_reference/notification_datecreated_criterion.md
|
||
description: Notification DateCreated Search Criterion | ||
month_change: true | ||
--- | ||
|
||
# Notification DateCreated Criterion | ||
|
||
The `DateCreated` Search Criterion searches for notifications based on the date when they were created. | ||
|
||
## Arguments | ||
|
||
- `created` - date to be matched, provided as a `DateTimeInterface` object | ||
- `operator` - optional operator string (GTE, LTE) | ||
|
||
## Example | ||
|
||
### PHP | ||
|
||
```php hl_lines="19" | ||
dabrt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
[[= include_file('code_samples/notifications/src/Query/Search.php') =]] | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
Check warning on line 1 in docs/search/criteria_reference/notification_search_criteria.md
|
||
description: Notification Search Criteria | ||
month_change: true | ||
--- | ||
|
||
# Notification Search Criteria reference | ||
|
||
Notification Search Criteria are only supported by Notification Search (`NotificationService::findNotifications`). | ||
|
||
With these Criteria you can filter notifications by their notification creation date, notification status, and notification type. | ||
|
||
## Notification Search Criteria | ||
|
||
|Search Criterion|Search based on| | ||
|-----|-----| | ||
|[DateCreated](notification_datecreated_criterion.md)|Date and time when notification was created| | ||
|[Status](notification_status_criterion.md)|Status of the notification| | ||
|[Type](notification_type_criterion.md)|Type of the notification| |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
Check warning on line 1 in docs/search/criteria_reference/notification_status_criterion.md
|
||
description: Notification Status Search Criterion | ||
month_change: true | ||
--- | ||
|
||
# Notification Status Criterion | ||
|
||
The `Status` Search Criterion searches for notifications based on notification status. | ||
|
||
## Arguments | ||
|
||
- `status` - Boolean value that represents the status of the notification | ||
|
||
## Example | ||
|
||
### PHP | ||
|
||
```php hl_lines="14" | ||
dabrt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
[[= include_file('code_samples/notifications/src/Query/Search.php') =]] | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
Check warning on line 1 in docs/search/criteria_reference/notification_type_criterion.md
|
||
description: Type Search Criterion | ||
month_change: true | ||
--- | ||
|
||
# Type Criterion | ||
|
||
The `Type` Search Criterion searches for notifications by their types. | ||
|
||
## Arguments | ||
|
||
- `type` - string that represents the type of the notification, takes values defined in notification workflow | ||
|
||
## Example | ||
|
||
### PHP | ||
|
||
```php hl_lines="13" | ||
dabrt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
[[= include_file('code_samples/notifications/src/Query/Search.php') =]] | ||
``` |
dabrt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.