src/Entity/StudioMedia.php line 51

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
  4. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  5. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  6. use ApiPlatform\Metadata\ApiFilter;
  7. use ApiPlatform\Metadata\ApiResource;
  8. use ApiPlatform\Metadata\Get;
  9. use ApiPlatform\Metadata\GetCollection;
  10. use ApiPlatform\Serializer\Filter\PropertyFilter;
  11. use App\Repository\StudioMediaRepository;
  12. use DateTimeImmutable;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. use Doctrine\ORM\Mapping\OrderBy;
  16. use Symfony\Component\Serializer\Annotation\Groups;
  17. //openapi: false
  18. #[ORM\Entity(repositoryClassStudioMediaRepository::class)]
  19. #[ApiFilter(PropertyFilter::class)]
  20. #[ApiResource(
  21.     shortName'Studio Medien',
  22.     description'Studio API Medien',
  23.     operations: [
  24.         new Get(uriTemplate'/api-medien/{id}'),
  25.         new GetCollection(uriTemplate'/api-medien',  paginationEnabledfalse),
  26.     ],
  27.     formats: [
  28.         'jsonld',
  29.         'json',
  30.         'jsonhal',
  31.         'csv' => 'text/csv',
  32.     ],
  33.     normalizationContext: [
  34.         'groups' => ['api-medien:read'],
  35.     ],
  36.     denormalizationContext: [
  37.         'groups' => ['api-medien:write'],
  38.     ],
  39.     //paginationItemsPerPage: 10,
  40. ),
  41.     ApiFilter(
  42.     OrderFilter::class,
  43.     properties: [
  44.         'position' => 'ASC',
  45.     ]
  46. )]
  47. class StudioMedia
  48. {
  49.     #[ORM\Id]
  50.     #[ORM\GeneratedValue]
  51.     #[ORM\Column]
  52.     #[Groups(['api-medien:read','news:read','studio:read'])]
  53.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  54.     private ?int $id null;
  55.     #[ORM\Column(length255)]
  56.     #[Groups(['api-medien:read','news:read','studio:read','seo:read'])]
  57.     private ?string $original null;
  58.     #[ORM\Column(length255)]
  59.     #[Groups(['api-medien:read','news:read','studio:read','seo:read'])]
  60.     private ?string $filename null;
  61.     #[ORM\Column(length64)]
  62.     #[Groups(['api-medien:read','news:read','studio:read'])]
  63.     private ?string $size null;
  64.     #[ORM\Column(length24)]
  65.     #[Groups(['api-medien:read''news:read','studio:read','seo:read'])]
  66.     private ?string $type null;
  67.     #[ORM\Column(length24)]
  68.     #[Groups(['api-medien:read','news:read','studio:read','seo:read'])]
  69.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  70.     private ?string $handle null;
  71.     #[ORM\Column(length128)]
  72.     #[Groups(['api-medien:read','news:read','studio:read'])]
  73.     private ?string $mimeType null;
  74.     #[ORM\Column(length64nullabletrue)]
  75.     #[Groups(['api-medien:read','news:read','studio:read','seo:read'])]
  76.     private ?string $title null;
  77.     #[ORM\Column(length128nullabletrue)]
  78.     #[Groups(['api-medien:read','news:read','studio:read'])]
  79.     private ?string $alt null;
  80.     #[ORM\Column(length255nullabletrue)]
  81.     #[Groups(['api-medien:read','news:read','studio:read'])]
  82.     private ?string $description null;
  83.     #[ORM\Column(length128nullabletrue)]
  84.     #[Groups(['api-medien:read','news:read','studio:read'])]
  85.     private ?string $custom null;
  86.     #[ORM\Column]
  87.     #[Groups(['api-medien:read'])]
  88.     private ?DateTimeImmutable $createdAt null;
  89.     #[ORM\ManyToOne(inversedBy'studioMedia')]
  90.     #[ORM\JoinColumn(nullabletrue)]
  91.     #[Groups(['api-medien:read','news:read'])]
  92.     #[ApiFilter(SearchFilter::class, strategy'exact')]
  93.     protected ?Studio $studio;
  94.     #[ORM\ManyToOne(inversedBy'studioMedia')]
  95.     #[ORM\JoinColumn(nullabletrue)]
  96.     protected ?News $news;
  97.     #[ORM\Column(nullabletrueoptions: ['default' => 0])]
  98.     #[Groups(['api-medien:read'])]
  99.     //#[orderBY(['position'=>'ASC'])]
  100.     private ?int $position null;
  101.     /*#[ORM\ManyToOne(targetEntity: Studio::class)]
  102.     #[Groups(['api-medien:read'])]
  103.     #[ORM\JoinColumn(name: "studio_id", referencedColumnName: "id", nullable: true)]
  104.     protected ?Studio $studioMedia;*/
  105.     public function __construct()
  106.     {
  107.         $this->createdAt = new DateTimeImmutable();
  108.         $this->position 0;
  109.     }
  110.     public function getId(): ?int
  111.     {
  112.         return $this->id;
  113.     }
  114.     public function getOriginal(): ?string
  115.     {
  116.         return $this->original;
  117.     }
  118.     public function setOriginal(string $original): self
  119.     {
  120.         $this->original $original;
  121.         return $this;
  122.     }
  123.     public function getFilename(): ?string
  124.     {
  125.         return $this->filename;
  126.     }
  127.     public function setFilename(string $filename): self
  128.     {
  129.         $this->filename $filename;
  130.         return $this;
  131.     }
  132.     public function getSize(): ?string
  133.     {
  134.         return $this->size;
  135.     }
  136.     public function setSize(string $size): self
  137.     {
  138.         $this->size $size;
  139.         return $this;
  140.     }
  141.     public function getType(): ?string
  142.     {
  143.         return $this->type;
  144.     }
  145.     public function setType(string $type): self
  146.     {
  147.         $this->type $type;
  148.         return $this;
  149.     }
  150.     public function getHandle(): ?string
  151.     {
  152.         return $this->handle;
  153.     }
  154.     public function setHandle(string $handle): self
  155.     {
  156.         $this->handle $handle;
  157.         return $this;
  158.     }
  159.     public function getMimeType(): ?string
  160.     {
  161.         return $this->mimeType;
  162.     }
  163.     public function setMimeType(string $mimeType): self
  164.     {
  165.         $this->mimeType $mimeType;
  166.         return $this;
  167.     }
  168.     public function getTitle(): ?string
  169.     {
  170.         return $this->title;
  171.     }
  172.     public function setTitle(?string $title): self
  173.     {
  174.         $this->title $title;
  175.         return $this;
  176.     }
  177.     public function getAlt(): ?string
  178.     {
  179.         return $this->alt;
  180.     }
  181.     public function setAlt(?string $alt): self
  182.     {
  183.         $this->alt $alt;
  184.         return $this;
  185.     }
  186.     public function getDescription(): ?string
  187.     {
  188.         return $this->description;
  189.     }
  190.     public function setDescription(?string $description): self
  191.     {
  192.         $this->description $description;
  193.         return $this;
  194.     }
  195.     public function getCustom(): ?string
  196.     {
  197.         return $this->custom;
  198.     }
  199.     public function setCustom(?string $custom): self
  200.     {
  201.         $this->custom $custom;
  202.         return $this;
  203.     }
  204.     public function getStudio(): ?Studio
  205.     {
  206.         return $this->studio;
  207.     }
  208.     public function setStudio(?Studio $studio): self
  209.     {
  210.         $this->studio $studio;
  211.         return $this;
  212.     }
  213.     public function getPosition(): ?int
  214.     {
  215.         return $this->position;
  216.     }
  217.     public function setPosition(?int $position): self
  218.     {
  219.         $this->position $position;
  220.         return $this;
  221.     }
  222.     public function getNews(): ?News
  223.     {
  224.         return $this->news;
  225.     }
  226.     public function setNews(?News $news): self
  227.     {
  228.         $this->news $news;
  229.         return $this;
  230.     }
  231.     public function getCreatedAt(): ?DateTimeImmutable
  232.     {
  233.         return $this->createdAt;
  234.     }
  235.     public function setCreatedAt(DateTimeImmutable $createdAt): self
  236.     {
  237.         $this->createdAt $createdAt;
  238.         return $this;
  239.     }
  240. }