src/Entity/MessagePrototype.php line 31

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\MessagePrototypeRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * @ORM\Entity(repositoryClass=MessagePrototypeRepository::class)
  10.  * @ApiResource(
  11.  *     denormalizationContext={
  12.  *          "groups"={"message_prototype:write"}
  13.  *     },
  14.  *     normalizationContext={
  15.  *          "groups"={"message_prototype:read"}
  16.  *     },
  17.  *     collectionOperations={
  18.  *          "post"={"security"="is_granted('ROLE_ADMIN')"},
  19.  *          "get"={"security"="is_granted('ROLE_USER')"},
  20.  *     },
  21.  *     itemOperations={
  22.  *          "get"={"security"="is_granted('ROLE_USER')"},
  23.  *          "delete"={"security"="is_granted('ROLE_ADMIN')"},
  24.  *          "patch"={"security"="is_granted('ROLE_ADMIN')"},
  25.  *     }
  26.  * )
  27.  */
  28. class MessagePrototype extends TvConfiguration
  29. {
  30.     /**
  31.      * @var string
  32.      * @Groups({"message_prototype:write","message_prototype:read"})
  33.      * @Assert\Type(type="string")
  34.      * @Assert\NotBlank(allowNull=false)
  35.      */
  36.     private $subject;
  37.     /**
  38.      * @var string
  39.      * @Groups({"message_prototype:write","message_prototype:read"})
  40.      * @Assert\Type(type="string")
  41.      * @Assert\NotBlank(allowNull=false)
  42.      * @Assert\Email
  43.      */
  44.     private $recipients;
  45.     /**
  46.      * @return string
  47.      */
  48.     public function getSubject() : ?string
  49.     {
  50.         $this->subject $this->subject??$this->field;
  51.         return $this->subject;
  52.     }
  53.     /**
  54.      * @param int|string $subject
  55.      * @return MessagePrototype
  56.      */
  57.     public function setSubject($subject): MessagePrototype
  58.     {
  59.         $this->subject $subject;
  60.         $this->field $subject;
  61.         return $this;
  62.     }
  63.     /**
  64.      * @return string
  65.      */
  66.     public function getRecipients(): ?string
  67.     {
  68.         $this->recipients $this->recipients??$this->value;
  69.         return $this->recipients;
  70.     }
  71.     /**
  72.      * @param string $recipients
  73.      * @return MessagePrototype
  74.      */
  75.     public function setRecipients(string $recipients): MessagePrototype
  76.     {
  77.         $this->recipients $recipients;
  78.         $this->value $recipients;
  79.         return $this;
  80.     }
  81.     public function setField(string $field): TvConfiguration
  82.     {
  83.         $this->field $field;
  84.         $this->subject $field;
  85.         return $this;
  86.     }
  87.     public function setValue(string $value): TvConfiguration
  88.     {
  89.         $this->value $value;
  90.         $this->recipients $value;
  91.         return $this;
  92.     }
  93. }