src/Entity/IndexationDatabase.php line 56

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