| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- declare (strict_types=1);
- namespace App\Entity\Core;
- use ApiPlatform\Metadata\Post;
- use ApiPlatform\Metadata\Get;
- use ApiPlatform\Metadata\ApiResource;
- use App\Entity\Access\Access;
- use App\Repository\Core\NotificationUserRepository;
- //use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use Doctrine\ORM\Mapping as ORM;
- /**
- *
- * Les NotificationUser permettent de garder la trace des notifications qui ont été lues par les utilisateurs
- */
- #[ApiResource(
- operations: [
- new Get(),
- new Post(
- securityPostDenormalize: 'object.getAccess().getId() == user.getId()
- and object.getNotification().getRecipientAccess().getOrganization().getId() == user.getOrganization().getId()'
- )
- ]
- )]
- //#[Auditable]
- #[ORM\Entity(repositoryClass: NotificationUserRepository::class)]
- class NotificationUser
- {
- #[ORM\Id]
- #[ORM\Column]
- #[ORM\GeneratedValue]
- private ?int $id = null;
- #[ORM\ManyToOne(inversedBy: 'notificationUsers')]
- #[ORM\JoinColumn(nullable: false)]
- private Notification $notification;
- #[ORM\ManyToOne(inversedBy: 'notificationUsers')]
- #[ORM\JoinColumn(nullable: false)]
- private Access $access;
- #[ORM\Column(nullable: false)]
- private bool $isRead = true;
- public function getId(): ?int
- {
- return $this->id;
- }
- public function setNotification(?Notification $notification): self
- {
- $this->notification = $notification;
- return $this;
- }
- public function getNotification(): Notification
- {
- return $this->notification;
- }
- public function setAccess(?Access $access): self
- {
- $this->access = $access;
- return $this;
- }
- public function getAccess(): Access
- {
- return $this->access;
- }
- public function setIsRead(?bool $isRead): self
- {
- $this->isRead = $isRead;
- return $this;
- }
- public function getIsRead(): ?bool
- {
- return $this->isRead;
- }
- }
|