mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-01 14:36:13 +00:00
notification: add notification sent to widget which list notifications
ont an entity
This commit is contained in:
parent
a8fe049ecd
commit
160d382e07
@ -36,11 +36,13 @@ class NotificationPresence
|
|||||||
*/
|
*/
|
||||||
public function getNotificationsForClassAndEntity(string $relatedEntityClass, int $relatedEntityId): array
|
public function getNotificationsForClassAndEntity(string $relatedEntityClass, int $relatedEntityId): array
|
||||||
{
|
{
|
||||||
if ($this->security->getUser() instanceof User) {
|
$user = $this->security->getUser();
|
||||||
return $this->notificationRepository->findNotificationAsAddresseeByRelatedEntityAndUser(
|
|
||||||
|
if ($user instanceof User) {
|
||||||
|
return $this->notificationRepository->findNotificationByRelatedEntityAndUserAssociated(
|
||||||
$relatedEntityClass,
|
$relatedEntityClass,
|
||||||
$relatedEntityId,
|
$relatedEntityId,
|
||||||
$this->security->getUser()
|
$user
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ final class NotificationRepository implements ObjectRepository
|
|||||||
/**
|
/**
|
||||||
* @return array|Notification[]
|
* @return array|Notification[]
|
||||||
*/
|
*/
|
||||||
public function findNotificationAsAddresseeByRelatedEntityAndUser(string $relatedEntityClass, int $relatedEntityId, User $user): array
|
public function findNotificationByRelatedEntityAndUserAssociated(string $relatedEntityClass, int $relatedEntityId, User $user): array
|
||||||
{
|
{
|
||||||
$qb = $this->repository->createQueryBuilder('n');
|
$qb = $this->repository->createQueryBuilder('n');
|
||||||
|
|
||||||
@ -156,7 +156,12 @@ final class NotificationRepository implements ObjectRepository
|
|||||||
->select('n')
|
->select('n')
|
||||||
->where($qb->expr()->eq('n.relatedEntityClass', ':relatedEntityClass'))
|
->where($qb->expr()->eq('n.relatedEntityClass', ':relatedEntityClass'))
|
||||||
->andWhere($qb->expr()->eq('n.relatedEntityId', ':relatedEntityId'))
|
->andWhere($qb->expr()->eq('n.relatedEntityId', ':relatedEntityId'))
|
||||||
->andWhere($qb->expr()->isMemberOf(':user', 'n.addressees'))
|
->andWhere(
|
||||||
|
$qb->expr()->orX(
|
||||||
|
$qb->expr()->isMemberOf(':user', 'n.addressees'),
|
||||||
|
$qb->expr()->eq('n.sender', ':user')
|
||||||
|
)
|
||||||
|
)
|
||||||
->setParameter('relatedEntityClass', $relatedEntityClass)
|
->setParameter('relatedEntityClass', $relatedEntityClass)
|
||||||
->setParameter('relatedEntityId', $relatedEntityId)
|
->setParameter('relatedEntityId', $relatedEntityId)
|
||||||
->setParameter('user', $user);
|
->setParameter('user', $user);
|
||||||
|
@ -2,7 +2,11 @@
|
|||||||
{% for notification in notifications %}
|
{% for notification in notifications %}
|
||||||
<div class="notification {% if notification.isReadBy(app.user) %}read{% else %}unread{% endif %}">
|
<div class="notification {% if notification.isReadBy(app.user) %}read{% else %}unread{% endif %}">
|
||||||
{% if not notification.isSystem %}
|
{% if not notification.isSystem %}
|
||||||
<div>{{ 'notification.you were notified by %sender%'|trans({'%sender%': notification.sender|chill_entity_render_string }) }}</div>
|
{% if notification.sender == app.user %}
|
||||||
|
<div>You sent notification to: {% for a in notification.addressees %}{{ a|chill_entity_render_string }}{% if not loop.last %}, {% endif %}{% endfor %}</div>
|
||||||
|
{% else %}
|
||||||
|
<div>{{ 'notification.you were notified by %sender%'|trans({'%sender%': notification.sender|chill_entity_render_string }) }}</div>
|
||||||
|
{% endif %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<div>{{ 'notification.you were notified by system'|trans }}</div>
|
<div>{{ 'notification.you were notified by system'|trans }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user