src/Entity/StudioContent.php line 53

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  4. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  5. use ApiPlatform\Metadata\ApiFilter;
  6. use ApiPlatform\Metadata\ApiResource;
  7. use ApiPlatform\Metadata\Get;
  8. use ApiPlatform\Metadata\GetCollection;
  9. use ApiPlatform\Serializer\Filter\PropertyFilter;
  10. use App\Repository\StudioContentRepository;
  11. use DateTimeImmutable;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\Common\Collections\Collection;
  14. use Doctrine\DBAL\Types\Types;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use Doctrine\ORM\Mapping\OrderBy;
  17. use Symfony\Component\Serializer\Annotation\Groups;
  18. #[ORM\Entity(repositoryClassStudioContentRepository::class)]
  19. /*#[ApiFilter(PropertyFilter::class)]
  20. #[ApiResource(
  21.     shortName: 'Studio',
  22.     description: 'Studio API',
  23.     operations: [
  24.         new Get(uriTemplate: '/content/{id}'),
  25.         //new Patch(uriTemplate: '/media/{id}'),
  26.         new GetCollection(uriTemplate: '/content', paginationEnabled: false),
  27.     ],
  28.     formats: [
  29.         'jsonld',
  30.         'json',
  31.         'jsonhal',
  32.         'csv' => 'text/csv',
  33.     ],
  34.     normalizationContext: [
  35.         'groups' => ['content:read'],
  36.     ],
  37.     denormalizationContext: [
  38.         'groups' => ['content:write'],
  39.     ],
  40.     // paginationItemsPerPage: 10,
  41. ),
  42.     ApiFilter(
  43.         OrderFilter::class,
  44.         properties: [
  45.             'position',
  46.         ],
  47.     ),
  48. ]*/
  49. class StudioContent
  50. {
  51.     #[ORM\Id]
  52.     #[ORM\GeneratedValue]
  53.     #[ORM\Column]
  54.     #[Groups(['studio:read','content:read'])]
  55.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  56.     private ?int $id null;
  57.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  58.     #[Groups(['studio:read','content:read'])]
  59.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  60.     private ?string $content null;
  61.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  62.     #[Groups(['studio:read','content:read'])]
  63.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  64.     private ?string $impressum null;
  65.     #[ORM\OneToOne(mappedBy'studioContent'targetEntityStudio::class)]
  66.     protected Studio $studio;
  67.     #[ORM\Column]
  68.     private ?DateTimeImmutable $createdAt null;
  69.     #[ORM\Column(nullabletrue)]
  70.     #[Groups(['studio:read','content:read'])]
  71.     private array $customFields = [];
  72.    // #[ORM\OneToMany(mappedBy: 'studioContent', targetEntity: Mediathek::class, cascade: ["persist"], orphanRemoval: true)]
  73.    // public Collection $gallery;
  74.     public function __construct()
  75.     {
  76.         $this->customFields = [];
  77.         $this->createdAt = new DateTimeImmutable();
  78.        // $this->gallery = new ArrayCollection();
  79.     }
  80.     public function getId(): ?int
  81.     {
  82.         return $this->id;
  83.     }
  84.     public function getContent(): ?string
  85.     {
  86.         return $this->content;
  87.     }
  88.     public function setContent(?string $content): self
  89.     {
  90.         $this->content $content;
  91.         return $this;
  92.     }
  93.     public function getImpressum(): ?string
  94.     {
  95.         return $this->impressum;
  96.     }
  97.     public function setImpressum(?string $impressum): self
  98.     {
  99.         $this->impressum $impressum;
  100.         return $this;
  101.     }
  102.     public function getCreatedAt(): ?DateTimeImmutable
  103.     {
  104.         return $this->createdAt;
  105.     }
  106.     public function setCreatedAt(DateTimeImmutable $createdAt): self
  107.     {
  108.         $this->createdAt $createdAt;
  109.         return $this;
  110.     }
  111.     public function getStudio(): ?Studio
  112.     {
  113.         return $this->studio;
  114.     }
  115.     public function getCustomFields(): array
  116.     {
  117.         return $this->customFields;
  118.     }
  119.     public function setCustomFields(?array $customFields): self
  120.     {
  121.         $this->customFields $customFields;
  122.         return $this;
  123.     }
  124.     public function setStudio(?Studio $studio): self
  125.     {
  126.         // unset the owning side of the relation if necessary
  127.         if ($studio === null && $this->studio !== null) {
  128.             $this->studio->setStudioContent(null);
  129.         }
  130.         // set the owning side of the relation if necessary
  131.         if ($studio !== null && $studio->getStudioContent() !== $this) {
  132.             $studio->setStudioContent($this);
  133.         }
  134.         $this->studio $studio;
  135.         return $this;
  136.     }
  137. }