src/Entity/EmailTemplates.php line 53

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Doctrine\Common\Filter\SearchFilterInterface;
  4. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  5. use ApiPlatform\Metadata\ApiFilter;
  6. use ApiPlatform\Metadata\ApiResource;
  7. use ApiPlatform\Metadata\Delete;
  8. use ApiPlatform\Metadata\Get;
  9. use ApiPlatform\Metadata\GetCollection;
  10. use ApiPlatform\Metadata\Patch;
  11. use ApiPlatform\Metadata\Post;
  12. use ApiPlatform\Serializer\Filter\PropertyFilter;
  13. use App\AppHelper\Helper;
  14. use App\Repository\EmailTemplatesRepository;
  15. use DateTimeImmutable;
  16. use Doctrine\DBAL\Types\Types;
  17. use Doctrine\ORM\Mapping as ORM;
  18. use Symfony\Component\Serializer\Annotation\Groups;
  19. use Symfony\Component\Validator\Constraints as Assert;
  20. use Carbon\Carbon;
  21. use function Symfony\Component\String\u;
  22. #[ORM\Entity(repositoryClassEmailTemplatesRepository::class)]
  23. /*#[ApiFilter(PropertyFilter::class)]
  24. #[ApiResource(
  25.     shortName: 'E-Mail-Templates',
  26.     description: 'App E-Mail Templates.',
  27.     operations: [
  28.         new Get(uriTemplate: '/email-template/{id}'),
  29.         new GetCollection(uriTemplate: '/email-template'),
  30.         new Post(uriTemplate: '/email-template'),
  31.         new Patch(uriTemplate: '/email-template/{id}'),
  32.         new Delete(uriTemplate: '/email-template/{id}')
  33.     ],
  34.     formats: [
  35.         'jsonld',
  36.         'json',
  37.         'jsonhal',
  38.         'html',
  39.         'csv' => 'text/csv',
  40.     ],
  41.     normalizationContext: [
  42.         'groups' => ['template:read'],
  43.     ],
  44.     denormalizationContext: [
  45.         'groups' => ['template:write'],
  46.     ],
  47.     paginationItemsPerPage: 10
  48. )]
  49. */
  50. class EmailTemplates
  51. {
  52.     #[ORM\Id]
  53.     #[ORM\GeneratedValue]
  54.     #[ORM\Column]
  55.    // #[Groups(['template:read'])]
  56.     private ?int $id null;
  57.     #[ORM\Column(length64)]
  58.    // #[Groups(['template:read', 'template:write'])]
  59.    // #[ApiFilter(SearchFilter::class, strategy: 'exact')]
  60.     #[Assert\NotBlank]
  61.     private ?string $type null;
  62.     #[ORM\Column(nullabletrue)]
  63.     private ?int $system_type null;
  64.     #[ORM\Column(length255)]
  65.   //  #[Groups(['template:read', 'template:write'])]
  66.  //   #[ApiFilter(SearchFilter::class, strategy: 'partial')]
  67.     #[Assert\NotBlank]
  68.     private ?string $subject null;
  69.     #[ORM\Column(nullabletrueoptions: ['default' => 0] )]
  70.     private ?int $position null;
  71.     #[ORM\Column(typeTypes::TEXTlength255)]
  72.     #[Groups(['template:read''template:write'])]
  73.     #[Assert\NotBlank]
  74.     private ?string $bezeichnung null;
  75.     #[ORM\Column(typeTypes::TEXT options: ['default' => 'no content'])]
  76.     #[Groups(['template:write'])]
  77.     #[Assert\NotBlank]
  78.     #[Assert\Length(min6minMessage'There must be at least 6 characters.')]
  79.     private ?string $content null;
  80.     #[ORM\Column]
  81.     #[Groups(['template:read'])]
  82.     private ?DateTimeImmutable $created_at null;
  83.     public function __construct()
  84.     {
  85.         $this->created_at = new DateTimeImmutable();
  86.     }
  87.     public function getId(): ?int
  88.     {
  89.         return $this->id;
  90.     }
  91.     public function getType(): ?string
  92.     {
  93.         return $this->type;
  94.     }
  95.     public function setType(string $type): self
  96.     {
  97.         $this->type $type;
  98.         return $this;
  99.     }
  100.     public function getSystemType(): ?int
  101.     {
  102.         return $this->system_type;
  103.     }
  104.     public function setSystemType(?int $system_type): self
  105.     {
  106.         $this->system_type $system_type;
  107.         return $this;
  108.     }
  109.     public function getSubject(): ?string
  110.     {
  111.         return $this->subject;
  112.     }
  113.     public function setSubject(string $subject): self
  114.     {
  115.         $this->subject $subject;
  116.         return $this;
  117.     }
  118.     public function getPosition(): ?int
  119.     {
  120.         return $this->position;
  121.     }
  122.     public function setPosition(?int $position): self
  123.     {
  124.         $this->position $position;
  125.         return $this;
  126.     }
  127.     public function getBezeichnung(): ?string
  128.     {
  129.         return $this->bezeichnung;
  130.     }
  131.     public function setBezeichnung(string $bezeichnung): self
  132.     {
  133.         $this->bezeichnung $bezeichnung;
  134.         return $this;
  135.     }
  136.     public function getContent(): ?string
  137.     {
  138.         return $this->content;
  139.     }
  140.     #[Groups(['template:read'])]
  141.     public function getContentFormat(): ?string
  142.     {
  143.         return html_entity_decode($this->content);
  144.     }
  145.     public function setContent(string $content): self
  146.     {
  147.         $this->content $content;
  148.         return $this;
  149.     }
  150.     public function getCreatedAt(): ?DateTimeImmutable
  151.     {
  152.         return $this->created_at;
  153.     }
  154.     #[Groups(['template:read'])]
  155.     public function getCreatedFormat(): ?string
  156.     {
  157.         return $this->created_at->format('Y-m-d H:i:s');
  158.     }
  159.     public function setCreatedAt(DateTimeImmutable $created_at): self
  160.     {
  161.         $this->created_at $created_at;
  162.         return $this;
  163.     }
  164. }