Skip to content

Commit 9cca895

Browse files
committed
Merge branch '4.6'
2 parents 7748f68 + 7fccfd2 commit 9cca895

File tree

3 files changed

+55
-9
lines changed

3 files changed

+55
-9
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
3+
<file source-language="en" target-language="en" datatype="plaintext" original="not.available">
4+
<header>
5+
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
6+
<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>
7+
</header>
8+
<body>
9+
<trans-unit id="b03e8123321d8b69e3e3d209bb58a0c0d3e5bf7f" resname="notifications.notification.system.label">
10+
<source>System notification</source>
11+
<target state="new">System notification</target>
12+
<note>key: notifications.notification.system.label</note>
13+
</trans-unit>
14+
</body>
15+
</file>
16+
</xliff>

src/bundle/Resources/views/themes/admin/notification/system_notification.html.twig

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends '@ibexadesign/account/notifications/list_item.html.twig' %}
1+
{% extends base_template %}
22

33
{% trans_default_domain 'ibexa_notification' %}
44

@@ -18,9 +18,7 @@
1818
{% endblock %}
1919

2020
{% block message %}
21-
{% embed '@ibexadesign/ui/component/table/table_body_cell.html.twig' with { class: 'ibexa-notifications-modal__description' } %}
22-
{% block content %}
23-
<p class="description__text">{{ content|default('') }}</p>
24-
{% endblock %}
25-
{% endembed %}
21+
{% block content %}
22+
<p title="{{ content|default('') }}" class="description__text{% if content|length > 100 %} description__text--ellipsis{% endif %}">{{ content|default('') }}</p>
23+
{% endblock %}
2624
{% endblock %}

src/lib/SystemNotification/SystemNotificationRenderer.php

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@
1010

1111
use Ibexa\Contracts\Core\Repository\Values\Notification\Notification;
1212
use Ibexa\Core\Notification\Renderer\NotificationRenderer;
13+
use Ibexa\Core\Notification\Renderer\TypedNotificationRendererInterface;
14+
use JMS\TranslationBundle\Annotation\Desc;
15+
use Symfony\Component\HttpFoundation\RequestStack;
1316
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
17+
use Symfony\Contracts\Translation\TranslatorInterface;
1418
use Twig\Environment;
1519

16-
final class SystemNotificationRenderer implements NotificationRenderer
20+
final class SystemNotificationRenderer implements NotificationRenderer, TypedNotificationRendererInterface
1721
{
1822
private const KEY_ICON = 'icon';
1923
private const KEY_ROUTE_NAME = 'route_name';
@@ -25,14 +29,31 @@ final class SystemNotificationRenderer implements NotificationRenderer
2529

2630
private UrlGeneratorInterface $urlGenerator;
2731

28-
public function __construct(Environment $twig, UrlGeneratorInterface $urlGenerator)
29-
{
32+
private RequestStack $requestStack;
33+
34+
private TranslatorInterface $translator;
35+
36+
public function __construct(
37+
Environment $twig,
38+
UrlGeneratorInterface $urlGenerator,
39+
RequestStack $requestStack,
40+
TranslatorInterface $translator
41+
) {
3042
$this->twig = $twig;
3143
$this->urlGenerator = $urlGenerator;
44+
$this->requestStack = $requestStack;
45+
$this->translator = $translator;
3246
}
3347

3448
public function render(Notification $notification): string
3549
{
50+
$baseTemplate = '@ibexadesign/account/notifications/list_item.html.twig';
51+
52+
$currentRequest = $this->requestStack->getCurrentRequest();
53+
if ($currentRequest !== null && $currentRequest->attributes->getBoolean('render_all')) {
54+
$baseTemplate = '@ibexadesign/account/notifications/list_item_all.html.twig';
55+
}
56+
3657
return $this->twig->render(
3758
'@ibexadesign/notification/system_notification.html.twig',
3859
[
@@ -41,6 +62,7 @@ public function render(Notification $notification): string
4162
'content' => $notification->data[self::KEY_CONTENT] ?? null,
4263
'subject' => $notification->data[self::KEY_SUBJECT] ?? null,
4364
'created_at' => $notification->created,
65+
'base_template' => $baseTemplate,
4466
]
4567
);
4668
}
@@ -56,4 +78,14 @@ public function generateUrl(Notification $notification): ?string
5678
$notification->data[self::KEY_ROUTE_PARAMS] ?? []
5779
);
5880
}
81+
82+
public function getTypeLabel(): string
83+
{
84+
return $this->translator->trans(
85+
/** @Desc("System notification") */
86+
'notifications.notification.system.label',
87+
[],
88+
'ibexa_notifications'
89+
);
90+
}
5991
}

0 commit comments

Comments
 (0)