diff --git a/src/Bundle/ChillMainBundle/Entity/Notification.php b/src/Bundle/ChillMainBundle/Entity/Notification.php index bf7aac4b3..e566a8d78 100644 --- a/src/Bundle/ChillMainBundle/Entity/Notification.php +++ b/src/Bundle/ChillMainBundle/Entity/Notification.php @@ -74,9 +74,14 @@ class Notification implements TrackUpdateInterface /** * @ORM\ManyToOne(targetEntity=User::class) - * @ORM\JoinColumn(nullable=false) + * @ORM\JoinColumn(nullable=true) */ - private User $sender; + private ?User $sender = null; + + /** + * @ORM\Column(type="text", options={"default": ""}) + */ + private string $title = ''; /** * @ORM\ManyToMany(targetEntity=User::class) @@ -179,6 +184,11 @@ class Notification implements TrackUpdateInterface return $this->sender; } + public function getTitle(): string + { + return $this->title; + } + public function getUnreadBy(): Collection { return $this->unreadBy; @@ -199,6 +209,11 @@ class Notification implements TrackUpdateInterface return !$this->unreadBy->contains($user); } + public function isSystem(): bool + { + return null === $this->sender; + } + public function markAsReadBy(User $user): self { return $this->removeUnreadBy($user); @@ -299,6 +314,13 @@ class Notification implements TrackUpdateInterface return $this; } + public function setTitle(string $title): Notification + { + $this->title = $title; + + return $this; + } + public function setUpdatedAt(DateTimeInterface $datetime): self { $this->updatedAt = $datetime; diff --git a/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php b/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php index e003a5afc..afb6eba19 100644 --- a/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php +++ b/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php @@ -1,5 +1,14 @@ security = $security; diff --git a/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtension.php b/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtension.php index 529da2bc1..115adf06b 100644 --- a/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtension.php +++ b/src/Bundle/ChillMainBundle/Notification/Templating/NotificationTwigExtension.php @@ -1,5 +1,14 @@ $notifications, ]); } - } diff --git a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php index 755b5f2dd..68c6b8be6 100644 --- a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php @@ -134,9 +134,17 @@ final class NotificationRepository implements ObjectRepository } /** - * @param string $relatedEntityClass - * @param int $relatedEntityId - * @param User $user + * @param mixed|null $limit + * @param mixed|null $offset + * + * @return Notification[] + */ + public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + /** * @return array|Notification[] */ public function findNotificationAsAddresseeByRelatedEntityAndUser(string $relatedEntityClass, int $relatedEntityId, User $user): array @@ -150,23 +158,11 @@ final class NotificationRepository implements ObjectRepository ->andWhere($qb->expr()->isMemberOf(':user', 'n.addressees')) ->setParameter('relatedEntityClass', $relatedEntityClass) ->setParameter('relatedEntityId', $relatedEntityId) - ->setParameter('user', $user) - ; + ->setParameter('user', $user); return $qb->getQuery()->getResult(); } - /** - * @param mixed|null $limit - * @param mixed|null $offset - * - * @return Notification[] - */ - public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null): array - { - return $this->repository->findBy($criteria, $orderBy, $limit, $offset); - } - public function findOneBy(array $criteria, ?array $orderBy = null): ?Notification { return $this->repository->findOneBy($criteria, $orderBy); diff --git a/src/Bundle/ChillMainBundle/Resources/views/Notification/extension_list_notifications_for.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Notification/extension_list_notifications_for.html.twig index db6aa5d13..5e5d1dba8 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Notification/extension_list_notifications_for.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Notification/extension_list_notifications_for.html.twig @@ -1,7 +1,11 @@