Skip to content

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

Open
wants to merge 4 commits into
base: 5.0
Choose a base branch
from
Open

IBX-9060: Document revamped notifications #2797

wants to merge 4 commits into from

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

Copy link

github-actions bot commented Jul 3, 2025

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 Symfony\Component\HttpFoundation\RequestStack;
010⫶use Symfony\Component\Routing\RouterInterface;
011⫶use Twig\Environment;
012⫶
013⫶class ListRenderer implements NotificationRenderer
014⫶{
015⫶ protected Environment $twig;
016⫶
017⫶ protected RouterInterface $router;
018⫶
019⫶ protected RequestStack $requestStack;
020⫶
021⫶ public function __construct(Environment $twig, RouterInterface $router, RequestStack $requestStack)
022⫶ {
023⫶ $this->twig = $twig;
024⫶ $this->router = $router;
025⫶ $this->requestStack = $requestStack;
026⫶ }
027⫶
028⫶ public function render(Notification $notification): string
029⫶ {
030⫶ $templateToExtend = '@ibexadesign/account/notifications/list_item.html.twig';
031⫶ $currentRequest = $this->requestStack->getCurrentRequest();
032⫶ if ($currentRequest && $currentRequest->attributes->getBoolean('render_all')) {
033⫶ $templateToExtend = '@ibexadesign/account/notifications/list_item_all.html.twig';
034⫶ }
035⫶
036⫶ return $this->twig->render('@ibexadesign/notification.html.twig', [
037⫶ 'notification' => $notification,
038⫶ 'template_to_extend' => $templateToExtend,
039⫶ ]);
040⫶ }
041⫶
042⫶ public function generateUrl(Notification $notification): ?string
043⫶ {
044⫶ if (array_key_exists('content_id', $notification->data)) {
045⫶ return $this->router->generate('ibexa.content.view', [
046⫶ 'contentId' => $notification->data['content_id'],
047⫶ ]);
048⫶ }
049⫶
050⫶ return null;
051⫶ }
052⫶}


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;
009⫶use Symfony\Component\Routing\RouterInterface;
010⫶use Twig\Environment;
011⫶
012⫶class MyRenderer implements NotificationRenderer
013⫶{
014⫶ protected Environment $twig;
015⫶
016⫶ protected RouterInterface $router;
017⫶
018⫶ public function __construct(Environment $twig, RouterInterface $router)
019⫶ {
020⫶ $this->twig = $twig;
021⫶ $this->router = $router;
022⫶ }
023⫶
024⫶ public function render(Notification $notification): string
025⫶ {

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⫶ protected Environment $twig;
015⫶
016⫶ protected RouterInterface $router;
017⫶
018⫶ public function __construct(Environment $twig, RouterInterface $router)
019⫶ {
020⫶ $this->twig = $twig;
021⫶ $this->router = $router;
022⫶ }
023⫶
024⫶ public function render(Notification $notification): string
025⫶ {
026⫶        return $this->twig->render('@ibexadesign/notification.html.twig', ['notification' => $notification]);
027⫶ }
028⫶
029⫶ public function generateUrl(Notification $notification): ?string
030⫶ {
031⫶ if (array_key_exists('content_id', $notification->data)) {
032⫶ return $this->router->generate('ibexa.content.view', ['contentId' => $notification->data['content_id']]);
033⫶ }
034⫶
035⫶ return null;
036⫶ }
037⫶}
026⫶        return $this->twig->render('@ibexadesign/notification.html.twig', [
027⫶ 'notification' => $notification,
028⫶ 'template_to_extend' => $templateToExtend,
029⫶ ]);
030⫶ }
031⫶
032⫶ public function generateUrl(Notification $notification): ?string
033⫶ {
034⫶ if (array_key_exists('content_id', $notification->data)) {
035⫶ return $this->router->generate('ibexa.content.view', ['contentId' => $notification->data['content_id']]);
036⫶ }
037⫶
038⫶ return null;
039⫶ }
040⫶}


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">
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

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('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

Download colorized diff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant