From a03ba22c9dd2e17fb54ce1301bf1e897f0ba208a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20D=C4=85browski?= <64841871+dabrt@users.noreply.github.com> Date: Thu, 26 Jun 2025 17:17:52 +0200 Subject: [PATCH 1/4] IBX-9060: Document revamped notifications --- docs/api/event_reference/other_events.md | 15 ++++++---- .../notification_datecreated_criterion.md | 26 ++++++++++++++++++ .../notification_search_criteria.md | 18 ++++++++++++ .../notification_status_criterion.md | 22 +++++++++++++++ .../notification_type_criterion.md | 22 +++++++++++++++ .../icon_twig_functions.md | 4 ++- .../img/icons/expand-right.png | Bin 0 -> 2402 bytes .../img/icons/mail-open.png | Bin 0 -> 1174 bytes .../img/icons/mail.svg.png | Bin 531 -> 833 bytes mkdocs.yml | 6 ++++ 10 files changed, 106 insertions(+), 7 deletions(-) create mode 100644 docs/search/criteria_reference/notification_datecreated_criterion.md create mode 100644 docs/search/criteria_reference/notification_search_criteria.md create mode 100644 docs/search/criteria_reference/notification_status_criterion.md create mode 100644 docs/search/criteria_reference/notification_type_criterion.md create mode 100644 docs/templating/twig_function_reference/img/icons/expand-right.png create mode 100644 docs/templating/twig_function_reference/img/icons/mail-open.png diff --git a/docs/api/event_reference/other_events.md b/docs/api/event_reference/other_events.md index c8d07ffcc0..b9f054ddd0 100644 --- a/docs/api/event_reference/other_events.md +++ b/docs/api/event_reference/other_events.md @@ -1,6 +1,7 @@ --- description: Events that are triggered when working with bookmarks, notifications, settings, forms and others. page_type: reference +month_change: true --- # Other events @@ -22,12 +23,14 @@ The following events refer to [notifications displayed in the user menu](notific | Event | Dispatched by | Properties | |---|---|---| -|`BeforeCreateNotificationEvent`|`NotificationService::createNotification`|`CreateStruct $createStruct`
`Notification|null $notification`| -|`CreateNotificationEvent`|`NotificationService::createNotification`|`Notification $notification`
`CreateStruct $createStruct`| -|`BeforeDeleteNotificationEvent`|`NotificationService::deleteNotification`|`Notification $notification`| -|`DeleteNotificationEvent`|`NotificationService::deleteNotification`|`Notification $notification`| -|`BeforeMarkNotificationAsReadEvent`|`NotificationService::markNotificationAsRead`|`Notification $notification`| -|`MarkNotificationAsReadEvent`|`NotificationService::markNotificationAsRead`|`Notification $notification`| +|[`BeforeCreateNotificationEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Events-Notification-BeforeCreateNotificationEvent.html)|[`NotificationService::createNotification`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-NotificationService.html#method_createNotification)|`CreateStruct $createStruct`
`Notification|null $notification`| +|[`CreateNotificationEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Events-Notification-CreateNotificationEvent.html)|[`NotificationService::createNotification`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-NotificationService.html#method_createNotification)|`Notification $notification`
`CreateStruct $createStruct`| +|[`BeforeDeleteNotificationEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Events-Notification-BeforeDeleteNotificationEvent.html)|[`NotificationService::deleteNotification`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-NotificationService.html#method_deleteNotification)|`Notification $notification`| +|[`DeleteNotificationEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Events-Notification-DeleteNotificationEvent.html)|[`NotificationService::deleteNotification`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-NotificationService.html#method_deleteNotification)|`Notification $notification`| +|[`BeforeMarkNotificationAsReadEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Events-Notification-BeforeMarkNotificationAsReadEvent.html)|[`NotificationService::markNotificationAsRead`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-NotificationService.html#method_markNotificationAsRead)|`Notification $notification`| +|[`MarkNotificationAsReadEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Events-Notification-MarkNotificationAsReadEvent.html)|[`NotificationService::markNotificationAsRead`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-NotificationService.html#method_markNotificationAsRead)|`Notification $notification`| +|[`BeforeMarkNotificationAsUnreadEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Events-Notification-BeforeMarkNotificationAsUnreadEvent.html)|[`NotificationService::markNotificationAsUnread`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-NotificationService.html#method_markNotificationAsUnread)|`Notification $notification`| +|[`MarkNotificationAsUnreadEvent`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-Events-Notification-MarkNotificationAsUnreadEvent.html)|[`NotificationService::markNotificationAsUnread`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-Core-Repository-NotificationService.html#method_markNotificationAsUnread)|`Notification $notification`| ## Settings diff --git a/docs/search/criteria_reference/notification_datecreated_criterion.md b/docs/search/criteria_reference/notification_datecreated_criterion.md new file mode 100644 index 0000000000..3888076a78 --- /dev/null +++ b/docs/search/criteria_reference/notification_datecreated_criterion.md @@ -0,0 +1,26 @@ +--- +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 +$criteria = new Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion\DateCreated( + new DateTime('2023-03-01 14:07:02'), + 'GTE' +); + +$query = new NotificationQuery($criteria); +``` diff --git a/docs/search/criteria_reference/notification_search_criteria.md b/docs/search/criteria_reference/notification_search_criteria.md new file mode 100644 index 0000000000..0dc037bb51 --- /dev/null +++ b/docs/search/criteria_reference/notification_search_criteria.md @@ -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| diff --git a/docs/search/criteria_reference/notification_status_criterion.md b/docs/search/criteria_reference/notification_status_criterion.md new file mode 100644 index 0000000000..fd2a898219 --- /dev/null +++ b/docs/search/criteria_reference/notification_status_criterion.md @@ -0,0 +1,22 @@ +--- +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 +$criteria = new Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion\(0); + +$query = new NotificationQuery($criteria); +``` diff --git a/docs/search/criteria_reference/notification_type_criterion.md b/docs/search/criteria_reference/notification_type_criterion.md new file mode 100644 index 0000000000..7455d5df2c --- /dev/null +++ b/docs/search/criteria_reference/notification_type_criterion.md @@ -0,0 +1,22 @@ +--- +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 +$criteria = new Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion\Type('Workflow:Reject'); + +$query = new NotificationQuery($criteria); +``` diff --git a/docs/templating/twig_function_reference/icon_twig_functions.md b/docs/templating/twig_function_reference/icon_twig_functions.md index a503f46d0b..f780c74129 100644 --- a/docs/templating/twig_function_reference/icon_twig_functions.md +++ b/docs/templating/twig_function_reference/icon_twig_functions.md @@ -1,7 +1,7 @@ --- description: Icon Twig functions enable referencing SVG icons in templates. page_type: reference -month_change: false +month_change: true --- # Icon Twig functions @@ -181,6 +181,7 @@ The following icons are available out-of-the-box: | ![error-icon](img/icons/error-icon.svg.png) | `error-icon` | | ![error](img/icons/error.svg.png) | `error` | | ![expand-left](img/icons/expand-left.svg.png) | `expand-left` | +| ![expand-right](img/icons/expand-right.png). | `expand-right` | | ![explore](img/icons/explore.svg.png) | `explore` | | ![events-collected](img/icons/events-collected.svg.png) | `events-collected` | | ![facebook](img/icons/facebook.svg.png) | `facebook` | @@ -254,6 +255,7 @@ The following icons are available out-of-the-box: | ![logout](img/icons/logout.svg.png) | `logout` | | ![maform](img/icons/maform.svg.png) | `maform` | | ![mail](img/icons/mail.svg.png) | `mail` | +| ![mail-open](img/icons/mail-open.png) | `mail-open` | | ![markup](img/icons/markup.svg.png) | `markup` | | ![media-type](img/icons/media-type.svg.png) | `media-type` | | ![media](img/icons/media.svg.png) | `media` | diff --git a/docs/templating/twig_function_reference/img/icons/expand-right.png b/docs/templating/twig_function_reference/img/icons/expand-right.png new file mode 100644 index 0000000000000000000000000000000000000000..9939b0145174c35980fb58054edaa8ef45302459 GIT binary patch literal 2402 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 literal 0 HcmV?d00001 diff --git a/docs/templating/twig_function_reference/img/icons/mail.svg.png b/docs/templating/twig_function_reference/img/icons/mail.svg.png index 68d4f263a0d9bd92f7976afbe85a91a59b309ff6..562e9ef34c7c9b1174417aa1ae3c9aacf9a457b2 100644 GIT binary patch literal 833 zcmeAS@N?(olHy`uVBq!ia0vp^3P3Eu!3-qV^zySYFfaxO_=LCuxlmwitfHc#prF7j ztsxY}o0qOz*O(&|ETszS0Vf--6%(yAh|>cT(-R0dM14n%@dn!+;b!qRF& zvOqyKuoO^SO$4Z28YChDv>K>I8mLi4NCqqgmK6aS4pa|O12h@L2AKmC1nLFa1(KCf z7Xgca*&w4J3P5V0Y@lO6THpvM4wAw|K*K?TKx3g=z^+w;kO=i)>;C`$f9J#lSzwsv zl?3?(GcYo^B1q&yzju_z55RzKY8~2<*V0k-+%b{ z>GPK_U%!6;@$={J-+%u8Ta>bLHPB|pByV?@f*TAuB|x^4r;B5V#`)Sy*X^4UW!gSU z-&|xgd8+TW>u2WOR90>Y?^<#F>;L(dFCJh161V*O_ZQ!7CY3+=e{9bsscmbu()fKC zYxK5=Uf;(buVCSED6N%il~v2_TmgxF)fTHx-oG1O5R;zLAmyiUXVUKP`wzt}{nsF4 zJ%JSv- zn&H`o|EvlTJYo-%G<&D2<<2==qd22!L-0S18O^Kqx81A}*wC>k4UEa{HEjtmSN`?>!lvVtU&J%W50 z7^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+10f+@+{-GzZ+Rj;xUkjGx) z>Fdh=l8K35pXfC^*D|Gv-K}VU^y&Gwy<& Date: Thu, 3 Jul 2025 15:21:47 +0200 Subject: [PATCH 2/4] Add modified query examples --- .../src/Notification/ListRenderer.php | 50 +++++++++++++++++++ .../notifications/Src/Query/search.php | 21 ++++++++ .../back_office/notifications.md | 16 +++++- .../notification_datecreated_criterion.md | 9 +--- .../notification_status_criterion.md | 6 +-- .../notification_type_criterion.md | 6 +-- 6 files changed, 92 insertions(+), 16 deletions(-) create mode 100644 code_samples/back_office/notifications/src/Notification/ListRenderer.php create mode 100644 code_samples/notifications/Src/Query/search.php diff --git a/code_samples/back_office/notifications/src/Notification/ListRenderer.php b/code_samples/back_office/notifications/src/Notification/ListRenderer.php new file mode 100644 index 0000000000..55ebbadc90 --- /dev/null +++ b/code_samples/back_office/notifications/src/Notification/ListRenderer.php @@ -0,0 +1,50 @@ +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; + } +} diff --git a/code_samples/notifications/Src/Query/search.php b/code_samples/notifications/Src/Query/search.php new file mode 100644 index 0000000000..1dcfd70928 --- /dev/null +++ b/code_samples/notifications/Src/Query/search.php @@ -0,0 +1,21 @@ +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); diff --git a/docs/administration/back_office/notifications.md b/docs/administration/back_office/notifications.md index fdf5f0cc0c..05551433cd 100644 --- a/docs/administration/back_office/notifications.md +++ b/docs/administration/back_office/notifications.md @@ -63,7 +63,9 @@ Example: [[= include_file('code_samples/back_office/notifications/src/EventListener/ContentPublishEventListener.php') =]] ``` -To display the notification, write a renderer and tag it as a service. +### Display single notification + +To display a single notification, write a renderer and tag it as a service. The example below presents a renderer that uses Twig to render a view: @@ -83,6 +85,18 @@ Finally, you need to add an entry to `config/services.yaml`: [[= include_file('code_samples/back_office/notifications/config/custom_services.yaml') =]] ``` +### Display notification list + +To display a list of notifications, expand the above renderer. + +The example below presents a modified renderer that uses Twig to render a list view: + +```php +[[= include_file('code_samples/back_office/notifications/src/Notification/ListRenderer.php') =]] +``` + +Then, add the templates that are defined above as a response to `render_all` request: + ## Notification timeout To define the timeout for hiding Back-Office notification bars, per notification type, use the `ibexa.system..notifications..timeout` [configuration key](configuration.md#configuration-files): diff --git a/docs/search/criteria_reference/notification_datecreated_criterion.md b/docs/search/criteria_reference/notification_datecreated_criterion.md index 3888076a78..a984edcbd5 100644 --- a/docs/search/criteria_reference/notification_datecreated_criterion.md +++ b/docs/search/criteria_reference/notification_datecreated_criterion.md @@ -16,11 +16,6 @@ The `DateCreated` Search Criterion searches for notifications based on the date ### PHP -``` php -$criteria = new Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion\DateCreated( - new DateTime('2023-03-01 14:07:02'), - 'GTE' -); - -$query = new NotificationQuery($criteria); +```php hl_lines="19" +[[= include_file('code_samples/notifications/src/Query/Search.php') =]] ``` diff --git a/docs/search/criteria_reference/notification_status_criterion.md b/docs/search/criteria_reference/notification_status_criterion.md index fd2a898219..fa49e3024e 100644 --- a/docs/search/criteria_reference/notification_status_criterion.md +++ b/docs/search/criteria_reference/notification_status_criterion.md @@ -15,8 +15,6 @@ The `Status` Search Criterion searches for notifications based on notification s ### PHP -``` php -$criteria = new Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion\(0); - -$query = new NotificationQuery($criteria); +```php hl_lines="14" +[[= include_file('code_samples/notifications/src/Query/Search.php') =]] ``` diff --git a/docs/search/criteria_reference/notification_type_criterion.md b/docs/search/criteria_reference/notification_type_criterion.md index 7455d5df2c..7c10ed357c 100644 --- a/docs/search/criteria_reference/notification_type_criterion.md +++ b/docs/search/criteria_reference/notification_type_criterion.md @@ -15,8 +15,6 @@ The `Type` Search Criterion searches for notifications by their types. ### PHP -``` php -$criteria = new Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion\Type('Workflow:Reject'); - -$query = new NotificationQuery($criteria); +```php hl_lines="13" +[[= include_file('code_samples/notifications/src/Query/Search.php') =]] ``` From 676c74bcf7f8461ac472e3eb4ef6fc88c578720d Mon Sep 17 00:00:00 2001 From: dabrt Date: Thu, 3 Jul 2025 13:33:05 +0000 Subject: [PATCH 3/4] PHP & JS CS Fixes --- .../notifications/src/Notification/ListRenderer.php | 4 +++- code_samples/notifications/Src/Query/search.php | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/code_samples/back_office/notifications/src/Notification/ListRenderer.php b/code_samples/back_office/notifications/src/Notification/ListRenderer.php index 55ebbadc90..7bef669299 100644 --- a/code_samples/back_office/notifications/src/Notification/ListRenderer.php +++ b/code_samples/back_office/notifications/src/Notification/ListRenderer.php @@ -32,12 +32,13 @@ public function render(Notification $notification): string 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)) { @@ -45,6 +46,7 @@ public function generateUrl(Notification $notification): ?string 'contentId' => $notification->data['content_id'], ]); } + return null; } } diff --git a/code_samples/notifications/Src/Query/search.php b/code_samples/notifications/Src/Query/search.php index 1dcfd70928..d771b8b343 100644 --- a/code_samples/notifications/Src/Query/search.php +++ b/code_samples/notifications/Src/Query/search.php @@ -2,8 +2,6 @@ declare(strict_types=1); -use DateTimeImmutable; -use Ibexa\Contracts\Core\Repository\Values\Notification\Query\Criterion; use Ibexa\Contracts\Core\Repository\Values\NotificationQuery; $repository = $this->getRepository(); From b52a11191b5ef5db908fd833676f8d850b38f241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20D=C4=85browski?= <64841871+dabrt@users.noreply.github.com> Date: Thu, 3 Jul 2025 16:05:31 +0200 Subject: [PATCH 4/4] Clarify templates that require modification --- .../notifications/src/Notification/MyRenderer.php | 5 ++++- .../templates/themes/admin/notification.html.twig | 2 +- docs/administration/back_office/notifications.md | 2 -- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/code_samples/back_office/notifications/src/Notification/MyRenderer.php b/code_samples/back_office/notifications/src/Notification/MyRenderer.php index cb745cf6ab..0ed286c4ae 100644 --- a/code_samples/back_office/notifications/src/Notification/MyRenderer.php +++ b/code_samples/back_office/notifications/src/Notification/MyRenderer.php @@ -23,7 +23,10 @@ public function __construct(Environment $twig, RouterInterface $router) public function render(Notification $notification): string { - return $this->twig->render('@ibexadesign/notification.html.twig', ['notification' => $notification]); + return $this->twig->render('@ibexadesign/notification.html.twig', [ + 'notification' => $notification, + 'template_to_extend' => $templateToExtend, + ]); } public function generateUrl(Notification $notification): ?string diff --git a/code_samples/back_office/notifications/templates/themes/admin/notification.html.twig b/code_samples/back_office/notifications/templates/themes/admin/notification.html.twig index bf3f26b6f0..05f1448ee2 100644 --- a/code_samples/back_office/notifications/templates/themes/admin/notification.html.twig +++ b/code_samples/back_office/notifications/templates/themes/admin/notification.html.twig @@ -1,4 +1,4 @@ -{% extends '@ibexadesign/account/notifications/list_item.html.twig' %} +{% extends template_to_extend %} {% trans_default_domain 'custom_notification' %} diff --git a/docs/administration/back_office/notifications.md b/docs/administration/back_office/notifications.md index 05551433cd..ceef60186f 100644 --- a/docs/administration/back_office/notifications.md +++ b/docs/administration/back_office/notifications.md @@ -95,8 +95,6 @@ The example below presents a modified renderer that uses Twig to render a list v [[= include_file('code_samples/back_office/notifications/src/Notification/ListRenderer.php') =]] ``` -Then, add the templates that are defined above as a response to `render_all` request: - ## Notification timeout To define the timeout for hiding Back-Office notification bars, per notification type, use the `ibexa.system..notifications..timeout` [configuration key](configuration.md#configuration-files):