Skip to content

Conversation

dabrt
Copy link
Contributor

@dabrt dabrt commented Jun 26, 2025

Question Answer
JIRA Ticket IBX-9060
Versions 4.6+
Edition all

Document revamped notifications

Checklist

  • Text renders correctly
  • Text has been checked with vale
  • Description metadata is up to date

@dabrt dabrt assigned tbialcz and unassigned tbialcz Sep 8, 2025
@dabrt dabrt requested a review from tbialcz September 8, 2025 12:51
Copy link
Contributor

@mnocon mnocon left a comment

Choose a reason for hiding this comment

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

Thank you! Please have a look at the code highlights - I think they have moved after some changes to the code sample.

Copy link

code_samples/ change report

Before (on target branch)After (in current PR)

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


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

docs/administration/back_office/notifications.md@94:```php
docs/administration/back_office/notifications.md@95:[[= include_file('code_samples/back_office/notifications/src/Notification/ListRenderer.php') =]]
docs/administration/back_office/notifications.md@96:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Notification;
006⫶
007⫶use Ibexa\Contracts\Core\Repository\Values\Notification\Notification;
008⫶use Ibexa\Core\Notification\Renderer\NotificationRenderer;
009⫶use Ibexa\Core\Notification\Renderer\TypedNotificationRendererInterface;
010⫶use Symfony\Component\HttpFoundation\RequestStack;
011⫶use Symfony\Component\Routing\RouterInterface;
012⫶use Twig\Environment;
013⫶
014⫶class ListRenderer implements NotificationRenderer, TypedNotificationRendererInterface
015⫶{
016⫶ protected Environment $twig;
017⫶
018⫶ protected RouterInterface $router;
019⫶
020⫶ protected RequestStack $requestStack;
021⫶
022⫶ public function __construct(Environment $twig, RouterInterface $router, RequestStack $requestStack)
023⫶ {
024⫶ $this->twig = $twig;
025⫶ $this->router = $router;
026⫶ $this->requestStack = $requestStack;
027⫶ }
028⫶
029⫶ public function render(Notification $notification): string
030⫶ {
031⫶ $templateToExtend = '@ibexadesign/account/notifications/list_item.html.twig';
032⫶ $currentRequest = $this->requestStack->getCurrentRequest();
033⫶ if ($currentRequest && $currentRequest->attributes->getBoolean('render_all')) {
034⫶ $templateToExtend = '@ibexadesign/account/notifications/list_item_all.html.twig';
035⫶ }
036⫶
037⫶ return $this->twig->render('@ibexadesign/notification.html.twig', [
038⫶ 'notification' => $notification,
039⫶ 'template_to_extend' => $templateToExtend,
040⫶ ]);
041⫶ }
042⫶
043⫶ public function generateUrl(Notification $notification): ?string
044⫶ {
045⫶ if (array_key_exists('content_id', $notification->data)) {
046⫶ return $this->router->generate('ibexa.content.view', [
047⫶ 'contentId' => $notification->data['content_id'],
048⫶ ]);
049⫶ }
050⫶
051⫶ return null;
052⫶ }
053⫶
054⫶ public function getTypeLabel(): string
055⫶ {
056⫶ return /** @Desc("Workflow stage changed") */
057⫶ $this->translator->trans(
058⫶ 'workflow.notification.stage_change.label',
059⫶ [],
060⫶ 'ibexa_workflow'
061⫶ );
062⫶ }
063⫶}


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


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

docs/administration/back_office/notifications.md@70:```php
docs/administration/back_office/notifications.md@71:[[= include_file('code_samples/back_office/notifications/src/Notification/MyRenderer.php') =]]
docs/administration/back_office/notifications.md@72:```
docs/administration/back_office/notifications.md@72:```php
docs/administration/back_office/notifications.md@73:[[= include_file('code_samples/back_office/notifications/src/Notification/MyRenderer.php') =]]
docs/administration/back_office/notifications.md@74:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Notification;
006⫶
007⫶use Ibexa\Contracts\Core\Repository\Values\Notification\Notification;
008⫶use Ibexa\Core\Notification\Renderer\NotificationRenderer;

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶namespace App\Notification;
006⫶
007⫶use Ibexa\Contracts\Core\Repository\Values\Notification\Notification;
008⫶use Ibexa\Core\Notification\Renderer\NotificationRenderer;
009⫶use Symfony\Component\Routing\RouterInterface;
010⫶use Twig\Environment;
011⫶
012⫶class MyRenderer implements NotificationRenderer
013⫶{
014⫶ public function __construct(
015⫶ protected Environment $twig,
016⫶ protected RouterInterface $router
017⫶ ) {
018⫶ }
019⫶
020⫶ public function render(Notification $notification): string
021⫶ {
022⫶ return $this->twig->render('@ibexadesign/notification.html.twig', ['notification' => $notification]);
009⫶use Ibexa\Core\Notification\Renderer\TypedNotificationRendererInterface;
010⫶use Symfony\Component\Routing\RouterInterface;
011⫶use Twig\Environment;
012⫶
013⫶class MyRenderer implements NotificationRenderer, TypedNotificationRendererInterface
014⫶{
015⫶ protected Environment $twig;
016⫶
017⫶ protected RouterInterface $router;
018⫶
019⫶ public function __construct(Environment $twig, RouterInterface $router)
020⫶ {
021⫶ $this->twig = $twig;
022⫶ $this->router = $router;
023⫶    }
024⫶
023⫶    }
024⫶
025⫶    public function generateUrl(Notification $notification): ?string
025⫶    public function render(Notification $notification): string
026⫶    {
026⫶    {
027⫶        if (array_key_exists('content_id', $notification->data)) {
028⫶ return $this->router->generate('ibexa.content.view', ['contentId' => $notification->data['content_id']]);
029⫶ }
030⫶
031⫶ return null;
032⫶ }
033⫶}
027⫶        return $this->twig->render('@ibexadesign/notification.html.twig', [
028⫶ 'notification' => $notification,
029⫶ 'template_to_extend' => $templateToExtend,
030⫶ ]);
031⫶ }
032⫶
033⫶ public function generateUrl(Notification $notification): ?string
034⫶ {
035⫶ if (array_key_exists('content_id', $notification->data)) {
036⫶ return $this->router->generate('ibexa.content.view', ['contentId' => $notification->data['content_id']]);
037⫶ }
038⫶
039⫶ return null;
040⫶ }
041⫶
042⫶ }
043⫶
044⫶ public function getTypeLabel(): string
045⫶ {
046⫶ return /** @Desc("Workflow stage changed") */
047⫶ $this->translator->trans(
048⫶ 'workflow.notification.stage_change.label',
049⫶ [],
050⫶ 'ibexa_workflow'
051⫶ );
052⫶ }
053⫶}


code_samples/back_office/notifications/templates/themes/admin/notification.html.twig



code_samples/back_office/notifications/templates/themes/admin/notification.html.twig

docs/administration/back_office/notifications.md@76:```html+twig
docs/administration/back_office/notifications.md@77:[[= include_file('code_samples/back_office/notifications/templates/themes/admin/notification.html.twig') =]]
docs/administration/back_office/notifications.md@78:```
docs/administration/back_office/notifications.md@78:```html+twig
docs/administration/back_office/notifications.md@79:[[= include_file('code_samples/back_office/notifications/templates/themes/admin/notification.html.twig') =]]
docs/administration/back_office/notifications.md@80:```


001⫶{% extends '@ibexadesign/account/notifications/list_item.html.twig' %}
001⫶{% extends template_to_extend %}
002⫶
003⫶{% trans_default_domain 'custom_notification' %}
004⫶
005⫶{% set wrapper_additional_classes = 'css-class-custom' %}
006⫶
007⫶{% block icon %}
008⫶ <span class="type__icon">
009⫶ <svg class="ibexa-icon ibexa-icon--review">
002⫶
003⫶{% trans_default_domain 'custom_notification' %}
004⫶
005⫶{% set wrapper_additional_classes = 'css-class-custom' %}
006⫶
007⫶{% block icon %}
008⫶ <span class="type__icon">
009⫶ <svg class="ibexa-icon ibexa-icon--review">
010⫶            <use xlink:href="{{ ibexa_icon_path('visibility') }}"></use>
010⫶            <use xlink:href="{{ ibexa_icon_path('view') }}"></use>
011⫶        </svg>
012⫶ </span>
013⫶{% endblock %}
014⫶
015⫶{% block notification_type %}
016⫶ <span class="type__text">
017⫶ {{ 'Notice'|trans|desc('Notice') }}
018⫶ </span>
019⫶{% endblock %}
020⫶
021⫶{% block message %}
022⫶ {% embed '@ibexadesign/ui/component/table/table_body_cell.html.twig' with { class: 'ibexa-notifications-modal__description' } %}
023⫶ {% block content %}
024⫶ <p class="description__text">{{ notification.data.content_name }} {{ notification.data.message }}</p>
025⫶ {% endblock %}
026⫶ {% endembed %}
027⫶{% endblock %}


code_samples/notifications/Src/Query/search.php

011⫶        </svg>
012⫶ </span>
013⫶{% endblock %}
014⫶
015⫶{% block notification_type %}
016⫶ <span class="type__text">
017⫶ {{ 'Notice'|trans|desc('Notice') }}
018⫶ </span>
019⫶{% endblock %}
020⫶
021⫶{% block message %}
022⫶ {% embed '@ibexadesign/ui/component/table/table_body_cell.html.twig' with { class: 'ibexa-notifications-modal__description' } %}
023⫶ {% block content %}
024⫶ <p class="description__text">{{ notification.data.content_name }} {{ notification.data.message }}</p>
025⫶ {% endblock %}
026⫶ {% endembed %}
027⫶{% endblock %}


code_samples/notifications/Src/Query/search.php

docs/search/criteria_reference/notification_datecreated_criterion.md@19:```php hl_lines="14-15 17"
docs/search/criteria_reference/notification_datecreated_criterion.md@20:[[= include_file('code_samples/notifications/Src/Query/search.php') =]]
docs/search/criteria_reference/notification_datecreated_criterion.md@21:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶use Ibexa\Contracts\Core\Repository\Values\NotificationQuery;
006⫶
007⫶$repository = $this->getRepository();
008⫶$notificationService = $repository->getNotificationService();
009⫶$query = new NotificationQuery([], 0, 25);
010⫶
011⫶$query->addCriterion(new Type('Workflow:Review'));
012⫶$query->addCriterion(new Status(['unread']));
013⫶
014❇️$from = new \DateTimeImmutable('-7 days');
015❇️$to = new \DateTimeImmutable();
016⫶
017❇️$query->addCriterion(new DateCreated($from, $to));
018⫶
019⫶$notificationList = $notificationService->findNotifications($query);

docs/search/criteria_reference/notification_status_criterion.md@18:```php hl_lines="12"
docs/search/criteria_reference/notification_status_criterion.md@19:[[= include_file('code_samples/notifications/Src/Query/search.php') =]]
docs/search/criteria_reference/notification_status_criterion.md@20:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶use Ibexa\Contracts\Core\Repository\Values\NotificationQuery;
006⫶
007⫶$repository = $this->getRepository();
008⫶$notificationService = $repository->getNotificationService();
009⫶$query = new NotificationQuery([], 0, 25);
010⫶
011⫶$query->addCriterion(new Type('Workflow:Review'));
012❇️$query->addCriterion(new Status(['unread']));
013⫶
014⫶$from = new \DateTimeImmutable('-7 days');
015⫶$to = new \DateTimeImmutable();
016⫶
017⫶$query->addCriterion(new DateCreated($from, $to));
018⫶
019⫶$notificationList = $notificationService->findNotifications($query);

docs/search/criteria_reference/notification_type_criterion.md@18:```php hl_lines="11"
docs/search/criteria_reference/notification_type_criterion.md@19:[[= include_file('code_samples/notifications/Src/Query/search.php') =]]
docs/search/criteria_reference/notification_type_criterion.md@20:```

001⫶<?php
002⫶
003⫶declare(strict_types=1);
004⫶
005⫶use Ibexa\Contracts\Core\Repository\Values\NotificationQuery;
006⫶
007⫶$repository = $this->getRepository();
008⫶$notificationService = $repository->getNotificationService();
009⫶$query = new NotificationQuery([], 0, 25);
010⫶
011❇️$query->addCriterion(new Type('Workflow:Review'));
012⫶$query->addCriterion(new Status(['unread']));
013⫶
014⫶$from = new \DateTimeImmutable('-7 days');
015⫶$to = new \DateTimeImmutable();
016⫶
017⫶$query->addCriterion(new DateCreated($from, $to));
018⫶
019⫶$notificationList = $notificationService->findNotifications($query);

Download colorized diff

@dabrt dabrt merged commit 14e30c5 into 5.0 Sep 19, 2025
6 of 7 checks passed
@dabrt dabrt deleted the IBX-9060 branch September 19, 2025 16:26
dabrt added a commit that referenced this pull request Sep 19, 2025
* IBX-9060: Document revamped notifications

* Add modified query examples

* Apply suggestion from @mnocon

Co-authored-by: Marek Nocoń <[email protected]>

---------

Co-authored-by: dabrt <[email protected]>
Co-authored-by: Marek Nocoń <[email protected]>
julitafalcondusza pushed a commit that referenced this pull request Oct 1, 2025
* IBX-9060: Document revamped notifications

* Add modified query examples

* Apply suggestion from @mnocon

Co-authored-by: Marek Nocoń <[email protected]>

---------

Co-authored-by: dabrt <[email protected]>
Co-authored-by: Marek Nocoń <[email protected]>
julitafalcondusza added a commit that referenced this pull request Oct 16, 2025
* Installation and configuration for Collaborative Editing

* fixes after review

* fixes

* fixes - part 2

* api condensed on one page, configuration added

* PHP & JS CS Fixes

* Update build.yaml Python version (#2907)

* IBX-9060: Document revamped notifications (#2797)

* IBX-9060: Document revamped notifications

* Add modified query examples

* Apply suggestion from @mnocon

Co-authored-by: Marek Nocoń <[email protected]>

---------

Co-authored-by: dabrt <[email protected]>
Co-authored-by: Marek Nocoń <[email protected]>

* Reworded section for updating LTS Updates (#2905)

* Reworded section for updating LTS Updates

* [WIP] Updated Python

* Fixed EOLWhitespace

* Fixed Symbol attribute

* 4.6 PHP API Ref + Collaboration (#2913)

* fixes

* fixes, code added

* fixes

* fixes

* links fixed

* fixes after review

* fixes after review

* composer fixes

* sql files updated

* fixes

---------

Co-authored-by: julitafalcondusza <[email protected]>
Co-authored-by: julitafalcondusza <[email protected]>
Co-authored-by: Adrien Dupuis <[email protected]>
Co-authored-by: Tomasz Dąbrowski <[email protected]>
Co-authored-by: dabrt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants