src/Entity/JournalGlobalFooter.php line 59

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