Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/bundle/Resources/translations/ibexa_notifications.en.xliff
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file source-language="en" target-language="en" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
</header>
<body>
<trans-unit id="b03e8123321d8b69e3e3d209bb58a0c0d3e5bf7f" resname="notifications.notification.system.label">
<source>System notification</source>
<target state="new">System notification</target>
<note>key: notifications.notification.system.label</note>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends '@ibexadesign/account/notifications/list_item.html.twig' %}
{% extends template_to_extend %}

{% trans_default_domain 'ibexa_notification' %}

Expand All @@ -18,9 +18,7 @@
{% endblock %}

{% block message %}
{% embed '@ibexadesign/ui/component/table/table_body_cell.html.twig' with { class: 'ibexa-notifications-modal__description' } %}
{% block content %}
<p class="description__text">{{ content|default('') }}</p>
{% endblock %}
{% endembed %}
{% block content %}
<p title="{{ content|default('') }}" class="description__text">{{ content|default('') }}</p>
{% endblock %}
{% endblock %}
38 changes: 35 additions & 3 deletions src/lib/SystemNotification/SystemNotificationRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@

use Ibexa\Contracts\Core\Repository\Values\Notification\Notification;
use Ibexa\Core\Notification\Renderer\NotificationRenderer;
use Ibexa\Core\Notification\Renderer\TypedNotificationRendererInterface;
use JMS\TranslationBundle\Annotation\Desc;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment;

final class SystemNotificationRenderer implements NotificationRenderer
final class SystemNotificationRenderer implements NotificationRenderer, TypedNotificationRendererInterface
{
private const KEY_ICON = 'icon';
private const KEY_ROUTE_NAME = 'route_name';
Expand All @@ -25,14 +29,31 @@ final class SystemNotificationRenderer implements NotificationRenderer

private UrlGeneratorInterface $urlGenerator;

public function __construct(Environment $twig, UrlGeneratorInterface $urlGenerator)
{
private RequestStack $requestStack;

private TranslatorInterface $translator;

public function __construct(
Environment $twig,
UrlGeneratorInterface $urlGenerator,
RequestStack $requestStack,
TranslatorInterface $translator
) {
$this->twig = $twig;
$this->urlGenerator = $urlGenerator;
$this->requestStack = $requestStack;
$this->translator = $translator;
}

public function render(Notification $notification): string
{
$templateToExtend = '@ibexadesign/account/notifications/list_item.html.twig';

$currentRequest = $this->requestStack->getCurrentRequest();
if ($currentRequest !== null && $currentRequest->attributes->getBoolean('render_all')) {
$templateToExtend = '@ibexadesign/account/notifications/list_item_all.html.twig';
}

return $this->twig->render(
'@ibexadesign/notification/system_notification.html.twig',
[
Expand All @@ -41,6 +62,7 @@ public function render(Notification $notification): string
'content' => $notification->data[self::KEY_CONTENT] ?? null,
'subject' => $notification->data[self::KEY_SUBJECT] ?? null,
'created_at' => $notification->created,
'template_to_extend' => $templateToExtend,
]
);
}
Expand All @@ -56,4 +78,14 @@ public function generateUrl(Notification $notification): ?string
$notification->data[self::KEY_ROUTE_PARAMS] ?? []
);
}

public function getTypeLabel(): string
{
return /** @Desc("System notification") */
$this->translator->trans(
'notifications.notification.system.label',
[],
'ibexa_notifications'
);
}
}
Loading