-
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
Merged
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a03ba22
IBX-9060: Document revamped notifications
dabrt ca0e86d
Add modified query examples
dabrt 676c74b
PHP & JS CS Fixes
dabrt b52a111
Clarify templates that require modification
dabrt f24589f
Update MyRenderer.php
dabrt 0333d4f
Update ListRenderer.php
dabrt dcdd3a3
Update MyRenderer.php
dabrt 2b3047a
Apply suggestions from code review
dabrt 6501726
Revert conflicting changes
dabrt 64d3e75
PHP & JS CS Fixes
dabrt bcfdb17
Link fix
dabrt d5db454
Add missing file
dabrt 57e3b07
Apply suggestion from @mnocon
dabrt 5d85f8c
Apply suggestion from @mnocon
dabrt 6f5fcd9
Apply suggestion from @mnocon
dabrt b2645e2
Delete docs/templating/twig_function_reference/img/icons/expand-right…
dabrt bb3a648
Delete docs/templating/twig_function_reference/img/icons/mail-open.png
dabrt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
code_samples/back_office/notifications/src/Notification/ListRenderer.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?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\HttpFoundation\RequestStack; | ||
use Symfony\Component\Routing\RouterInterface; | ||
use Twig\Environment; | ||
|
||
class ListRenderer implements NotificationRenderer, TypedNotificationRendererInterface | ||
{ | ||
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
|
||
|
||
public function getTypeLabel(): string | ||
{ | ||
return /** @Desc("Workflow stage changed") */ | ||
$this->translator->trans( | ||
'workflow.notification.stage_change.label', | ||
[], | ||
'ibexa_workflow' | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
code_samples/back_office/notifications/templates/themes/admin/notification.html.twig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')); | ||
$query->addCriterion(new Status(['unread'])); | ||
|
||
$from = new \DateTimeImmutable('-7 days'); | ||
$to = new \DateTimeImmutable(); | ||
|
||
$query->addCriterion(new DateCreated($from, $to)); | ||
|
||
$notificationList = $notificationService->findNotifications($query); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
docs/search/criteria_reference/notification_datecreated_criterion.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
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') =]] | ||
``` |
18 changes: 18 additions & 0 deletions
18
docs/search/criteria_reference/notification_search_criteria.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
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| |
20 changes: 20 additions & 0 deletions
20
docs/search/criteria_reference/notification_status_criterion.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
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') =]] | ||
``` |
20 changes: 20 additions & 0 deletions
20
docs/search/criteria_reference/notification_type_criterion.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
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') =]] | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dabrt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+302 Bytes
(160%)
docs/templating/twig_function_reference/img/icons/mail.svg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.