src/Entity/Partner.php line 53

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM,
  4.     Doctrine\Common\Collections\ArrayCollection;
  5. use ApiPlatform\Metadata\ApiResource,
  6.     ApiPlatform\Metadata\Get,
  7.     ApiPlatform\Metadata\GetCollection,
  8.     ApiPlatform\Metadata\Post,
  9.     ApiPlatform\Metadata\Put,
  10.     ApiPlatform\Metadata\Delete,
  11.     ApiPlatform\Metadata\ApiFilter,
  12.     ApiPlatform\Doctrine\Orm\Filter\SearchFilter,
  13.     ApiPlatform\Doctrine\Orm\Filter\BooleanFilter,
  14.     ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  15. use App\Entity\Trait\IdTrait,
  16.     App\Entity\Trait\UuidTrait,
  17.     App\Entity\Trait\OrdStatTrait,
  18.     App\Entity\Trait\TimestampableTrait,
  19.     App\Entity\Trait\TranslatableTrait,
  20.     App\Entity\Trait\Languages\SiteLanguagesTrait,
  21.     App\Entity\Interface\TranslatableInterface,
  22.     App\Entity\Interface\OrdStatableInterface,
  23.     App\Entity\Interface\LanguageableInterface,
  24.     App\Repository\PartnerRepository,
  25.     App\Enum\Language;
  26. #[ApiResource(
  27.     description'Partners',
  28.     normalizationContext: ['groups' => [
  29.         'read',
  30.         'read:' self::class,
  31.         'read:' self::class . 'Translation'
  32.     ]],
  33.     denormalizationContext: ['groups' => ['write']],
  34.     security'is_granted("' self::class . '")',
  35.     order: ['ord' => 'desc'],
  36.     operations: [
  37.         new GetCollection(),
  38.         new Post(),
  39.         new Get(),
  40.         new Put(),
  41.         new Delete(),
  42.     ],
  43.     extraProperties: ['standard_put' => false],
  44. )]
  45. #[ApiFilter(SearchFilter::class, properties: ['translations.title' => 'partial''nativeTitle' => 'partial'])]
  46. #[ApiFilter(BooleanFilter::class, properties: ['stat'])]
  47. #[ApiFilter(OrderFilter::class, properties: ['nativeTitle''ord'])]
  48. #[ORM\Entity(repositoryClassPartnerRepository::class)]
  49. class Partner implements TranslatableInterfaceOrdStatableInterfaceLanguageableInterface
  50. {
  51.     use IdTrait,
  52.         UuidTrait,
  53.         OrdStatTrait,
  54.         TimestampableTrait,
  55.         TranslatableTrait,
  56.         SiteLanguagesTrait;
  57.     private ?PartnerFrontData $frontData null;
  58.     public function __construct(?array $languages)
  59.     {
  60.         $this->setUuid();
  61.         $this->translations = new ArrayCollection();
  62.         $this->setLanguages($languages ?? Language::DEFAULT_SITE);
  63.         $this->createdAt = new \DateTimeImmutable();
  64.         $this->updatedAt = new \DateTimeImmutable();
  65.     }
  66.     public function getFrontData(): PartnerFrontData
  67.     {
  68.         if (! $this->frontData) {
  69.             $this->frontData = new PartnerFrontData();
  70.         }
  71.         return $this->frontData;
  72.     }
  73. }