src/Entity/JournalFooter.php line 61

  1. <?php
  2. namespace App\Entity;
  3. use App\Filter\IriFilter;
  4. use App\Repository\JournalFooterRepository;
  5. use Doctrine\ORM\Mapping as ORM,
  6.     Doctrine\DBAL\Types\Types,
  7.     Doctrine\Common\Collections\ArrayCollection;
  8. use Symfony\Component\Serializer\Annotation\Groups,
  9.     Symfony\Component\Validator\Constraints as Assert;
  10. use ApiPlatform\Metadata\ApiResource,
  11.     ApiPlatform\Metadata\ApiProperty,
  12.     ApiPlatform\Metadata\Get,
  13.     ApiPlatform\Metadata\GetCollection,
  14.     ApiPlatform\Metadata\Post,
  15.     ApiPlatform\Metadata\Put,
  16.     ApiPlatform\Metadata\Delete,
  17.     ApiPlatform\Metadata\ApiFilter,
  18.     ApiPlatform\Doctrine\Orm\Filter\SearchFilter,
  19.     ApiPlatform\Doctrine\Orm\Filter\BooleanFilter,
  20.     ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  21. use App\Entity\Trait\IdTrait,
  22.     App\Entity\Trait\UuidTrait,
  23.     App\Entity\Trait\OrdStatTrait,
  24.     App\Entity\Trait\TimestampableTrait,
  25.     App\Entity\Trait\TranslatableTrait,
  26.     App\Entity\Trait\Languages\SiteLanguagesTrait,
  27.     App\Entity\Interface\TranslatableInterface,
  28.     App\Entity\Interface\OrdStatableInterface,
  29.     App\Entity\Interface\LanguageableInterface;
  30. use App\Enum\Language;
  31. #[ApiResource(
  32.     description'Journal global footer',
  33.     normalizationContext: ['groups' => [
  34.         'read',
  35.         'read:' self::class,
  36.         'read:' self::class . 'Translation'
  37.     ]],
  38.     denormalizationContext: ['groups' => ['write']],
  39.     security'is_granted("' self::class . '")',
  40.     order: ['ord' => 'desc'],
  41.     operations: [
  42.         new GetCollection(),
  43.         new Post(denormalizationContext: ['groups' => ['write',  'post']]),
  44.         new Get(),
  45.         new Put(),
  46.         new Delete(),
  47.     ],
  48.     extraProperties: ['standard_put' => false],
  49. )]
  50. #[ApiFilter(SearchFilter::class, properties: ['translations.title' => 'partial''workingTitle' => 'partial'])]
  51. #[ApiFilter(BooleanFilter::class, properties: ['stat'])]
  52. #[ApiFilter(OrderFilter::class, properties: ['workingTitle''ord'])]
  53. #[ApiFilter(IriFilter::class, properties: ['parent'])]
  54. #[ORM\Entity(repositoryClassJournalFooterRepository::class)]
  55. class JournalFooter implements TranslatableInterfaceOrdStatableInterfaceLanguageableInterface
  56. {
  57.     use IdTrait,
  58.         UuidTrait,
  59.         OrdStatTrait,
  60.         TimestampableTrait,
  61.         TranslatableTrait,
  62.         SiteLanguagesTrait;
  63.     #[ApiProperty(description'Working title')]
  64.     #[Groups(['read''write'])]
  65.     #[Assert\NotBlank]
  66.     #[ORM\Column(typeTypes::STRINGlength511uniquetrue)]
  67.     private string $workingTitle;
  68.     #[ApiProperty(description'Is target blank')]
  69.     #[Groups(['read:' self::class, 'write'])]
  70.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  71.     private bool $isTargetBlank false;
  72.     #[ApiProperty(description'Parent'readableLinkfalsewritableLinkfalse)]
  73.     #[Groups(['read''post'])]
  74.     #[Assert\NotNull]
  75.     #[ORM\ManyToOne(inversedBy'smallFooters')]
  76.     #[ORM\JoinColumn(nullablefalseonDelete'cascade')]
  77.     private ?Journal $parent null;
  78.     public function __construct(?array $languages)
  79.     {
  80.         $this->setUuid();
  81.         $this->translations = new ArrayCollection();
  82.         $this->setLanguages($languages ?? Language::DEFAULT_SITE);
  83.         $this->createdAt = new \DateTimeImmutable();
  84.         $this->updatedAt = new \DateTimeImmutable();
  85.     }
  86.     public function getWorkingTitle(): string
  87.     {
  88.         return $this->workingTitle;
  89.     }
  90.     public function setWorkingTitle(string $workingTitle): self
  91.     {
  92.         $this->workingTitle $workingTitle;
  93.         return $this;
  94.     }
  95.     public function getIsTargetBlank(): bool
  96.     {
  97.         return $this->isTargetBlank;
  98.     }
  99.     public function setIsTargetBlank(bool $isTargetBlank): self
  100.     {
  101.         $this->isTargetBlank $isTargetBlank;
  102.         return $this;
  103.     }
  104.     public function getParent(): ?Journal
  105.     {
  106.         return $this->parent;
  107.     }
  108.     public function setParent(?Journal $parent): self
  109.     {
  110.         $this->parent $parent;
  111.         return $this;
  112.     }
  113. }