Bläddra i källkod

Merge branch 'feature/fix_missing_discr_field' into develop

Olivier Massot 2 år sedan
förälder
incheckning
45cf8cada0

+ 4 - 0
.env.docker

@@ -54,3 +54,7 @@ MAILER_DSN=smtp://mailcatcher:1025
 ###> filename log ###
 LOG_FILE_NAME=docker
 ###< filename log ###
+
+### Internal requests (@see doc/internal_requests.md)
+INTERNAL_FILES_DOWNLOAD_URI=https://nginx/_internal/secure/files
+###

+ 4 - 0
.env.staging

@@ -46,3 +46,7 @@ MERCURE_PUBLIC_URL=https://none
 # The secret used to sign the JWTs
 MERCURE_JWT_SECRET=gEwnJpcR8k0xE2sfBpEJzzuP2b2TXhZnzImIqCUk3j4RStBZa2pQjbEMsnGE4iGM
 ###< symfony/mercure-bundle ###
+
+### Internal requests (@see doc/internal_requests.md)
+INTERNAL_FILES_DOWNLOAD_URI=https://none
+###

+ 5 - 1
.env.test

@@ -1,5 +1,5 @@
 ###> symfony/framework-bundle ###
-APP_DEBUG=0
+APP_DEBUG=1
 ###< symfony/framework-bundle ###
 
 ###> doctrine/doctrine-bundle ###
@@ -55,3 +55,7 @@ WKHTMLTOIMAGE_PATH=/usr/bin/wkhtmltoimage
 ###> filename log ###
 LOG_FILE_NAME=test
 ###< filename log ###
+
+### Internal requests (@see doc/internal_requests.md)
+INTERNAL_FILES_DOWNLOAD_URI=https://api.test1.opentalent.fr/_internal/secure/files
+###

+ 1 - 3
src/Doctrine/Core/CurrentUserNotificationExtension.php

@@ -31,12 +31,10 @@ final class CurrentUserNotificationExtension extends AbstractExtension
         $currentUser = $this->security->getUser();
         $rootAlias = $queryBuilder->getRootAliases()[0];
         $queryBuilder
-            ->andWhere(sprintf('%s.discr = :discr', $rootAlias))
             ->andWhere(sprintf('%s.recipientAccess = :current_access', $rootAlias))
             ->andWhere('o.availabilityDate IS NULL or o.availabilityDate <= :today')
-            ->setParameter('discr', 'notification')
             ->setParameter('current_access', $currentUser)
             ->setParameter('today', new \DateTime())
         ;
     }
-}
+}

+ 12 - 21
src/Entity/Core/AbstractInformation.php

@@ -26,16 +26,7 @@ use Symfony\Component\Serializer\Annotation\Context;
  *
  * Classe Notification. qui permet de gérer les notifications aux utilisateurs.
  */
-//#[ApiResource(
-//    operations: [
-//        new Get(),
-//        new GetCollection(
-//            paginationMaximumItemsPerPage: 20,
-//            paginationClientItemsPerPage: true,
-//            order: ['id' => 'DESC']
-//        )
-//    ]
-//)]
+#[ApiResource]
 //#[Auditable]
 #[ORM\Entity]
 #[ORM\Table(name: 'Information')]
@@ -50,41 +41,41 @@ class AbstractInformation
     #[ORM\Id]
     #[ORM\Column]
     #[ORM\GeneratedValue]
-    private ?int $id = null;
+    protected ?int $id = null;
 
     #[ORM\ManyToOne(inversedBy: 'notifications')]
     #[ORM\JoinColumn(nullable: false)]
-    private ?Access $recipientAccess;
+    protected ?Access $recipientAccess;
 
     #[ORM\ManyToOne(inversedBy: 'notifications')]
     #[ORM\JoinColumn(nullable: false)]
-    private ?Organization $recipientOrganization;
+    protected ?Organization $recipientOrganization;
 
     #[ORM\Column(length: 40, nullable: true)]
-    private ?string $name = null;
+    protected ?string $name = null;
 
     #[ORM\Column(type: 'datetime', nullable: true)]
-    private ?\DateTimeInterface $createDate;
+    protected ?\DateTimeInterface $createDate;
 
     #[ORM\Column(type: 'datetime', nullable: true)]
-    private ?\DateTimeInterface $updateDate;
+    protected ?\DateTimeInterface $updateDate;
 
     #[ORM\Column(type: 'json', length: 4294967295, nullable: true)]
-    private mixed $message = [];
+    protected mixed $message = [];
 
     #[ORM\Column(nullable: true)]
     #[Assert\Choice(callback: [NotificationTypeEnum::class, 'toArray'], message: 'invalid-type')]
-    private ?string $type = null;
+    protected ?string $type = null;
 
     #[ORM\Column(length: 255, nullable: true)]
-    private ?string $link = null;
+    protected ?string $link = null;
 
     #[ORM\Column(type: 'date', nullable: true)]
     #[Context(normalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
-    private ?\DateTimeInterface $availabilityDate = null;
+    protected ?\DateTimeInterface $availabilityDate = null;
 
     #[ORM\OneToMany(mappedBy: 'notification', targetEntity: NotificationUser::class, cascade: ['persist'], orphanRemoval: true)]
-    private Collection $notificationUsers;
+    protected Collection $notificationUsers;
 
     #[Pure]
     public function __construct()

+ 0 - 197
src/Entity/Core/Notification.php

@@ -40,202 +40,5 @@ use Symfony\Component\Serializer\Annotation\Context;
 #[ORM\Entity(repositoryClass: NotificationRepository::class)]
 class Notification extends AbstractInformation
 {
-    #[ORM\Id]
-    #[ORM\Column]
-    #[ORM\GeneratedValue]
-    private ?int $id = null;
 
-    #[ORM\ManyToOne(inversedBy: 'notifications')]
-    #[ORM\JoinColumn(nullable: false)]
-    private ?Access $recipientAccess;
-
-    #[ORM\ManyToOne(inversedBy: 'notifications')]
-    #[ORM\JoinColumn(nullable: false)]
-    private ?Organization $recipientOrganization;
-
-    #[ORM\Column(length: 40, nullable: true)]
-    private ?string $name = null;
-
-    #[ORM\Column(type: 'datetime', nullable: true)]
-    private ?\DateTimeInterface $createDate;
-
-    #[ORM\Column(type: 'datetime', nullable: true)]
-    private ?\DateTimeInterface $updateDate;
-
-    #[ORM\Column(type: 'json', length: 4294967295, nullable: true)]
-    private mixed $message = [];
-
-    #[ORM\Column(nullable: true)]
-    #[Assert\Choice(callback: [NotificationTypeEnum::class, 'toArray'], message: 'invalid-type')]
-    private ?string $type = null;
-
-    #[ORM\Column(length: 255, nullable: true)]
-    private ?string $link = null;
-
-    #[ORM\Column(type: 'date', nullable: true)]
-    #[Context(normalizationContext: [DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])]
-    private ?\DateTimeInterface $availabilityDate = null;
-
-    #[ORM\OneToMany(mappedBy: 'notification', targetEntity: NotificationUser::class, cascade: ['persist'], orphanRemoval: true)]
-    private Collection $notificationUsers;
-
-    #[Pure]
-    public function __construct()
-    {
-        $this->notificationUsers = new ArrayCollection();
-    }
-
-    public function getId(): ?int
-    {
-        return $this->id;
-    }
-
-    public function setName(?string $name): self
-    {
-        $this->name = $name;
-        return $this;
-    }
-
-    public function getName(): ?string
-    {
-        return $this->name;
-    }
-
-    public function setRecipientAccess(?Access $recipientAccess): self
-    {
-        $this->recipientAccess = $recipientAccess;
-        return $this;
-    }
-
-    public function getRecipientAccess(): ?Access
-    {
-        return $this->recipientAccess;
-    }
-
-    /**
-     * @return Organization|null
-     */
-    public function getRecipientOrganization(): ?Organization
-    {
-        return $this->recipientOrganization;
-    }
-
-    /**
-     * @param Organization|null $recipientOrganization
-     * @return Notification
-     */
-    public function setRecipientOrganization(?Organization $recipientOrganization): Notification
-    {
-        $this->recipientOrganization = $recipientOrganization;
-        return $this;
-    }
-
-    /**
-     * @return \DateTimeInterface|null
-     */
-    public function getCreateDate(): ?\DateTimeInterface
-    {
-        return $this->createDate;
-    }
-
-    /**
-     * @param \DateTimeInterface|null $createDate
-     */
-    public function setCreateDate(?\DateTimeInterface $createDate): self
-    {
-        $this->createDate = $createDate;
-        return $this;
-    }
-
-    /**
-     * @return \DateTimeInterface|null
-     */
-    public function getUpdateDate(): ?\DateTimeInterface
-    {
-        return $this->updateDate;
-    }
-
-    /**
-     * @param \DateTimeInterface|null $updateDate
-     */
-    public function setUpdateDate(?\DateTimeInterface $updateDate): self
-    {
-        $this->updateDate = $updateDate;
-        return $this;
-    }
-
-    public function setMessage(mixed $message): self
-    {
-        $this->message = $message;
-        return $this;
-    }
-
-    public function getMessage(): mixed
-    {
-        if (!is_array($this->message)) {
-            return ['about' => $this->message];
-        }
-        return $this->message;
-    }
-
-    public function setType(?string $type): self
-    {
-        $this->type = $type;
-        return $this;
-    }
-
-    public function getType(): ?string
-    {
-        return $this->type;
-    }
-
-    public function setLink(?string $link): self
-    {
-        $this->link = $link;
-        return $this;
-    }
-
-    public function getLink(): ?string
-    {
-        return $this->link;
-    }
-
-    public function getAvailabilityDate(): ?\DateTimeInterface
-    {
-        return $this->availabilityDate;
-    }
-
-    public function setAvailabilityDate(?\DateTime $availabilityDate = null): self
-    {
-        if ($availabilityDate == null) {
-            $availabilityDate = new \DateTime();
-        }
-        $this->availabilityDate = $availabilityDate;
-        return $this;
-    }
-
-    public function getNotificationUsers(): Collection
-    {
-        return $this->notificationUsers;
-    }
-
-    public function addNotificationUser(NotificationUser $notificationUsers): self
-    {
-        if (!$this->notificationUsers->contains($notificationUsers)) {
-            $this->notificationUsers[] = $notificationUsers;
-            $notificationUsers->setNotification($this);
-        }
-        return $this;
-    }
-
-    public function removeNotificationUser(NotificationUser $notificationUsers): self
-    {
-        if ($this->notificationUsers->removeElement($notificationUsers)) {
-            // set the owning side to null (unless already changed)
-            if ($notificationUsers->getNotification() === $this) {
-                $notificationUsers->setNotification(null);
-            }
-        }
-        return $this;
-    }
 }

+ 0 - 9
src/Entity/Core/Tips.php

@@ -28,13 +28,4 @@ use Doctrine\ORM\Mapping as ORM;
 #[ORM\Entity]
 class Tips extends AbstractInformation
 {
-    #[ORM\Id]
-    #[ORM\Column]
-    #[ORM\GeneratedValue]
-    private ?int $id = null;
-
-    public function getId(): ?int
-    {
-        return $this->id;
-    }
 }

+ 3 - 0
src/Entity/Message/AbstractMessage.php

@@ -24,6 +24,9 @@ abstract class AbstractMessage
     #[ORM\GeneratedValue]
     protected ?int $id = null;
 
+    #[ORM\Column(length: 255, nullable: false)]
+    protected string $discr;
+
     /**
      * @var UuidInterface|null
      */

+ 1 - 1
src/Entity/Message/Email.php

@@ -26,7 +26,7 @@ use Ramsey\Uuid\Uuid;
 class Email extends AbstractMessage
 {
     #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'email';
+    protected string $discr = 'email';
 
     #[ORM\Column(type: 'boolean', options: ['default' => false])]
     private bool $isSystem = false;

+ 2 - 2
src/Entity/Message/Mail.php

@@ -24,7 +24,7 @@ use Ramsey\Uuid\Uuid;
 class Mail extends AbstractMessage
 {
     #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'mail';
+    protected string $discr = 'mail';
 
     #[ORM\ManyToOne(inversedBy: 'mails')]
     #[ORM\JoinColumn(nullable: true)]
@@ -120,4 +120,4 @@ class Mail extends AbstractMessage
 
         return $this;
     }
-}
+}

+ 1 - 1
src/Entity/Message/Sms.php

@@ -25,7 +25,7 @@ use Ramsey\Uuid\Uuid;
 class Sms extends AbstractMessage
 {
     #[ORM\Column(length: 255, nullable: false)]
-    private string $discr = 'sms';
+    protected string $discr = 'sms';
 
     #[ORM\ManyToOne(inversedBy: 'sms')]
     #[ORM\JoinColumn(nullable: true)]