src/Entity/Studio.php line 67
<?phpnamespace App\Entity;use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter;use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;use ApiPlatform\Metadata\ApiFilter;use ApiPlatform\Metadata\ApiResource;use ApiPlatform\Metadata\Get;use ApiPlatform\Metadata\GetCollection;use ApiPlatform\Metadata\Patch;use ApiPlatform\Metadata\Post;use ApiPlatform\Metadata\Put;use ApiPlatform\Serializer\Filter\PropertyFilter;use App\Repository\StudioRepository;use DateTimeImmutable;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;use Doctrine\ORM\Mapping\OrderBy;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\Serializer\Annotation\Groups;#[ORM\Entity(repositoryClass: StudioRepository::class)]#[ApiFilter(PropertyFilter::class)]#[ApiResource(shortName: 'Studio',description: 'Studio API',operations: [new Get(uriTemplate: '/studio/{id}'),// new POST(uriTemplate: '/studio/{id}',security: "is_granted('ROLE_OAUTH2_BASIC')"),new GetCollection(uriTemplate: '/studio', paginationEnabled: false),new Patch(uriTemplate: '/studio/{id}',security: "is_granted('ROLE_OAUTH2_BASIC')"),],//,security: "is_granted('ROLE_OAUTH2_BASIC')"formats: ['jsonld','json','jsonhal','csv' => 'text/csv',],normalizationContext: ['groups' => ['studio:read'],],denormalizationContext: ['groups' => ['studio:write'],],// paginationItemsPerPage: 10,),ApiFilter(OrderFilter::class,properties: ['position','createdAt'],),ApiFilter(ExistsFilter::class,properties: ['siteSeo',],),]class Studio{#[ORM\Id]#[ORM\GeneratedValue]#[ORM\Column]#[Groups(['studio:read','news:read','seo:read'])]#[ApiFilter(SearchFilter::class, strategy: 'exact')]private ?int $id = null;#[ORM\Column(length: 64)]#[Groups(['studio:read','news:read','seo:read'])]#[ApiFilter(SearchFilter::class, strategy: 'exact')]private ?string $bezeichnung = null;#[ORM\Column(length: 64)]#[Groups(['studio:read','news:read', 'seo:read'])]#[ApiFilter(SearchFilter::class, strategy: 'exact')]private ?string $slug = null;#[ORM\Column(type: Types::SMALLINT)]#[Groups(['studio:read','news:read'])]#[ApiFilter(SearchFilter::class, strategy: 'exact')]private ?int $inPlanung = null;#[ORM\Column(type: Types::SMALLINT, nullable: true)]#[ApiFilter(SearchFilter::class, strategy: 'exact')]#[Groups(['studio:read','news:read'])]private ?int $geschlossen = null;#[ORM\ManyToOne(inversedBy: 'studio')]#[ORM\JoinColumn(nullable: true)]// #[ORM\JoinColumn(name: 'id',referencedColumnName: 'franchise_nehmer_id', nullable: true)]protected ?FranchiseNehmer $franchiseNehmer;#[ORM\OneToOne(inversedBy: "studio", targetEntity: GeoData::class, cascade: ["persist", "remove"])]#[ORM\JoinColumn(name: "geodaten", nullable: true)]#[Groups(['studio:read'])]protected ?GeoData $geodaten;#[ORM\OneToOne(inversedBy: "studio", targetEntity: StudioContent::class, cascade: ["persist", "remove"])]#[ORM\JoinColumn(name: "studioContent", nullable: true)]#[ApiFilter(SearchFilter::class, strategy: 'exact')]#[Groups(['studio:read'])]protected ?StudioContent $studioContent;#[ORM\OneToOne(inversedBy: "studio", targetEntity: StudioZeiten::class, cascade: ["persist", "remove"])]#[ORM\JoinColumn(name: "zeiten", nullable: true)]protected ?StudioZeiten $zeiten;#[ORM\OneToOne(inversedBy: "studio", targetEntity: SaunaZeiten::class, cascade: ["persist", "remove"])]#[ORM\JoinColumn(name: "saunaZeiten", nullable: true)]protected ?SaunaZeiten $saunazeiten;#[ORM\OneToOne(inversedBy: "studio", targetEntity: AccessZeiten::class, cascade: ["persist", "remove"])]#[ORM\JoinColumn(name: "accessZeiten", nullable: true)]protected ?AccessZeiten $accesszeiten;#[ORM\OneToOne(inversedBy: "studio", targetEntity: SupportZeiten::class, cascade: ["persist", "remove"])]#[ORM\JoinColumn(name: "supportZeiten", nullable: true)]protected ?SupportZeiten $supportZeiten;#[ORM\OneToOne(inversedBy: "studio", targetEntity: OpeningTimes::class, cascade: ["persist", "remove"])]#[ORM\JoinColumn(name: "openingTimes", nullable: true)]protected ?OpeningTimes $openingTimes;#[ORM\OneToOne(inversedBy: "studio", targetEntity: SiteSeo::class, cascade: ["persist", "remove"])]#[ORM\JoinColumn(name: "siteSeo", nullable: true)]#[Groups(['seo:read', 'seo:write','studio:write'])]protected ?SiteSeo $siteSeo;#[ORM\OneToOne(inversedBy: "studio", targetEntity: StudioKurse::class, cascade: ["persist", "remove"])]#[ORM\JoinColumn(name: "studioKurse", nullable: true)]//#[Groups(['studio:read'])]protected ?StudioKurse $studioKurse;// #[ORM\OneToMany(mappedBy: 'studio', targetEntity: Mediathek::class, cascade: ["persist"], orphanRemoval: true)]//#[Groups(['studio:read'])]// public Collection $mediathek;#[ORM\OneToMany(mappedBy: 'studio', targetEntity: StudioVideo::class, cascade: ["persist"], orphanRemoval: true)]#[Groups(['studio:read'])]public Collection $studioVideo;#[ORM\OneToMany(mappedBy: 'studio', targetEntity: StudioMedia::class, cascade: ["persist"], orphanRemoval: true)]#[Groups(['studio:read', 'seo:read'])]#[OrderBy(['position' => 'ASC'])]protected Collection $studioMedia;#[Groups(['studio:read'])]#[ApiFilter(SearchFilter::class, strategy: 'exact')]#[ORM\OneToMany(mappedBy: 'studio', targetEntity: News::class, cascade: ["persist"], orphanRemoval: true)]protected Collection $news;#[ORM\Column]private ?DateTimeImmutable $createdAt = null;#[ORM\Column(length: 128, nullable: true)]#[Groups(['studio:read'])]private ?string $website = null;#[ORM\Column(length: 32, nullable: true)]#[Groups(['studio:read'])]private ?string $telefon = null;#[ORM\Column(length: 32, nullable: true)]#[Groups(['studio:read'])]private ?string $mobil = null;#[ORM\Column(length: 32, nullable: true)]#[Groups(['studio:read'])]private ?string $fax = null;#[ORM\Column(length: 8, nullable: true)]#[Groups(['studio:read'])]private ?string $plz = null;#[ORM\Column(length: 64, nullable: true)]#[Groups(['studio:read'])]private ?string $ort = null;#[ORM\Column(length: 128, nullable: true)]#[Groups(['studio:read'])]private ?string $strasse = null;#[ORM\Column(length: 64, nullable: true)]#[Groups(['studio:read'])]private ?string $email = null;#[ORM\Column(nullable: true, options: ['default' => 0])]#[Groups(['studio:read'])]private ?int $position = null;#[ORM\Column(nullable: true)]private array $leistungen = [];public function __construct(){$this->createdAt = new DateTimeImmutable();$this->studioVideo = new ArrayCollection();$this->studioMedia = new ArrayCollection();$this->leistungen = [];$this->position = 0;$this->news = new ArrayCollection();$this->siteSeo = NULL;}public function getId(): ?int{return $this->id;}public function getBezeichnung(): ?string{return $this->bezeichnung;}public function setBezeichnung(string $bezeichnung): self{$this->bezeichnung = $bezeichnung;return $this;}public function getSlug(): ?string{return $this->slug;}public function setSlug(string $slug): self{$this->slug = $slug;return $this;}public function getInPlanung(): ?int{return $this->inPlanung;}public function setInPlanung(int $inPlanung): self{$this->inPlanung = $inPlanung;return $this;}public function getGeschlossen(): ?int{return $this->geschlossen;}public function setGeschlossen(int $geschlossen): self{$this->geschlossen = $geschlossen;return $this;}public function getCreatedAt(): ?DateTimeImmutable{return $this->createdAt;}public function setCreatedAt(DateTimeImmutable $createdAt): self{$this->createdAt = $createdAt;return $this;}#[Groups(['seo:read', 'studio:read'])]public function getOrderCreatedAt(): ?DateTimeImmutable{return $this->createdAt;}public function getFranchiseNehmer(): ?FranchiseNehmer{return $this->franchiseNehmer;}public function setFranchiseNehmer(?FranchiseNehmer $franchiseNehmer): self{$this->franchiseNehmer = $franchiseNehmer;return $this;}public function getWebsite(): ?string{return $this->website;}public function setWebsite(?string $website): self{$this->website = $website;return $this;}public function getTelefon(): ?string{return $this->telefon;}public function setTelefon(?string $telefon): self{$this->telefon = $telefon;return $this;}public function getMobil(): ?string{return $this->mobil;}public function setMobil(?string $mobil): self{$this->mobil = $mobil;return $this;}public function getFax(): ?string{return $this->fax;}public function setFax(?string $fax): self{$this->fax = $fax;return $this;}public function getPlz(): ?string{return $this->plz;}public function setPlz(?string $plz): self{$this->plz = $plz;return $this;}public function getOrt(): ?string{return $this->ort;}public function setOrt(?string $ort): self{$this->ort = $ort;return $this;}public function getStrasse(): ?string{return $this->strasse;}public function setStrasse(?string $strasse): self{$this->strasse = $strasse;return $this;}public function getEmail(): ?string{return $this->email;}public function setEmail(?string $email): self{$this->email = $email;return $this;}public function getGeodaten(): ?GeoData{return $this->geodaten;}public function setGeodaten(?GeoData $geodaten): self{$this->geodaten = $geodaten;return $this;}public function getZeiten(): ?StudioZeiten{return $this->zeiten;}public function setZeiten(?StudioZeiten $zeiten): self{$this->zeiten = $zeiten;return $this;}#[Groups(['studio:read'])]public function getSaunaZeiten(): ?SaunaZeiten{return $this->saunazeiten;}public function setSaunaZeiten(?SaunaZeiten $saunazeiten): self{$this->saunazeiten = $saunazeiten;return $this;}#[Groups(['studio:read'])]public function getAccessZeiten(): ?AccessZeiten{return $this->accesszeiten;}public function setAccessZeiten(?AccessZeiten $accesszeiten): self{$this->accesszeiten = $accesszeiten;return $this;}#[Groups(['studio:read'])]public function getSupportZeiten(): ?SupportZeiten{return $this->supportZeiten;}public function setSupportZeiten(?SupportZeiten $supportZeiten): self{$this->supportZeiten = $supportZeiten;return $this;}#[Groups(['studio:read'])]public function getOpeningTimes(): ?OpeningTimes{return $this->openingTimes;}public function setOpeningTimes(?OpeningTimes $openingTimes): self{$this->openingTimes = $openingTimes;return $this;}#[Groups(['studio:read'])]public function getSiteSeo(): ?SiteSeo{return $this->siteSeo;}public function setSiteSeo(?SiteSeo $siteSeo): self{$this->siteSeo = $siteSeo;return $this;}/*** @return Collection<int, StudioVideo>*/public function getStudioVideo(): Collection{return $this->studioVideo;}public function addStudioVideo(StudioVideo $studioVideo): self{if (!$this->studioVideo->contains($studioVideo)) {$this->studioVideo->add($studioVideo);$studioVideo->setStudio($this);}return $this;}public function removeStudioVideo(StudioVideo $studioVideo): self{if ($this->studioVideo->removeElement($studioVideo)) {// set the owning side to null (unless already changed)if ($studioVideo->getStudio() === $this) {$studioVideo->setStudio(null);}}return $this;}/*** @return Collection<int, StudioMedia>*/public function getStudioMedia(): Collection{return $this->studioMedia;}public function addStudioMedium(StudioMedia $studioMedium): self{if (!$this->studioMedia->contains($studioMedium)) {$this->studioMedia->add($studioMedium);$studioMedium->setStudio($this);}return $this;}public function removeStudioMedium(StudioMedia $studioMedium): self{if ($this->studioMedia->removeElement($studioMedium)) {// set the owning side to null (unless already changed)if ($studioMedium->getStudio() === $this) {$studioMedium->setStudio(null);}}return $this;}public function getPosition(): ?int{return $this->position;}public function setPosition(?int $position): self{$this->position = $position;return $this;}// #[Groups(['studio:read'])]public function getLogo(): ?array{$data = [];$request = Request::createFromGlobals();$selfUrl = $request->getSchemeAndHttpHost();foreach ($this->studioMedia as $tmp) {if ($tmp->getHandle() == 'studio-logo') {if ($tmp->getType() == 'image') {$full = '/uploads/full/';$large = '/uploads/large/';$medium = '/uploads/medium/';$thumb = '/uploads/thumb/';} else {$full = '/uploads/data/';$large = '/uploads/data/';$medium = '/uploads/data/';$thumb = '/uploads/data/';}$data = ['id' => $tmp->getId(),'filename' => $tmp->getFilename(),'original' => $tmp->getOriginal(),'title' => $tmp->getTitle(),'alt' => $tmp->getAlt(),'description' => $tmp->getDescription(),'custom' => $tmp->getCustom(),'self_url' => $selfUrl,'size' => $tmp->getSize(),'mimeType' => $tmp->getMimeType(),'variant' => ['full' => $full,'large' => $large,'medium' => $medium,'thumb' => $thumb],];}}return [$data];}// #[Groups(['studio:read'])]public function getTitleImage(): ?array{$data = [];$request = Request::createFromGlobals();$selfUrl = $request->getSchemeAndHttpHost();foreach ($this->studioMedia as $tmp) {if ($tmp->getHandle() == 'studio-titel') {if ($tmp->getType() == 'image') {$full = '/uploads/full/';$large = '/uploads/large/';$medium = '/uploads/medium/';$thumb = '/uploads/thumb/';} else {$full = '/uploads/data/';$large = '/uploads/data/';$medium = '/uploads/data/';$thumb = '/uploads/data/';}$data = ['id' => $tmp->getId(),'filename' => $tmp->getFilename(),'original' => $tmp->getOriginal(),'title' => $tmp->getTitle(),'alt' => $tmp->getAlt(),'description' => $tmp->getDescription(),'custom' => $tmp->getCustom(),'self_url' => $selfUrl,'size' => $tmp->getSize(),'mimeType' => $tmp->getMimeType(),'variant' => ['full' => $full,'large' => $large,'medium' => $medium,'thumb' => $thumb],];}}return [$data];}// #[Groups(['studio:read'])]public function getGalerie(): ?array{$a = [];$request = Request::createFromGlobals();$selfUrl = $request->getSchemeAndHttpHost();foreach ($this->studioMedia as $tmp) {if ($tmp->getHandle() == 'studio-galerie') {if ($tmp->getType() == 'image') {$full = '/uploads/full/';$large = '/uploads/large/';$medium = '/uploads/medium/';$thumb = '/uploads/thumb/';} else {$full = '/uploads/data/';$large = '/uploads/data/';$medium = '/uploads/data/';$thumb = '/uploads/data/';}$i = ['id' => $tmp->getId(),'filename' => $tmp->getFilename(),'original' => $tmp->getOriginal(),'title' => $tmp->getTitle(),'alt' => $tmp->getAlt(),'description' => $tmp->getDescription(),'custom' => $tmp->getCustom(),'self_url' => $selfUrl,'size' => $tmp->getSize(),'mimeType' => $tmp->getMimeType(),'variant' => ['full' => $full,'large' => $large,'medium' => $medium,'thumb' => $thumb],];$a[] = $i;}}return [$a];}// #[Groups(['studio:read'])]public function getVideo(): ?array{$map = $this->studioVideo;$t = [];foreach ($map as $tmp) {$item = ['filename' => $tmp->getFilename(),'cover' => $tmp->getCoverImg(),'mime_type' => $tmp->getMimeType(),'size' => $tmp->getFileSizeConvert()];$t[] = $item;}return [$t];}// #[Groups(['studio:read'])]public function getStudioZeiten(): ?array{if ($this->zeiten) {$montag = $this->zeiten->getMontag();$montag = json_decode($montag['data'], true);$montag['closed'] ? $montagZeiten = [] : $montagZeiten = $montag['zeiten'];$dienstag = $this->zeiten->getDienstag();$dienstag = json_decode($dienstag['data'], true);$dienstag['closed'] ? $dienstagZeiten = [] : $dienstagZeiten = $dienstag['zeiten'];$mittwoch = $this->zeiten->getMittwoch();$mittwoch = json_decode($mittwoch['data'], true);$mittwoch['closed'] ? $mittwochZeiten = [] : $mittwochZeiten = $mittwoch['zeiten'];$donnerstag = $this->zeiten->getDonnerstag();$donnerstag = json_decode($donnerstag['data'], true);$donnerstag['closed'] ? $donnerstagZeiten = [] : $donnerstagZeiten = $donnerstag['zeiten'];$freitag = $this->zeiten->getFreitag();$freitag = json_decode($freitag['data'], true);$freitag['closed'] ? $freitagZeiten = [] : $freitagZeiten = $freitag['zeiten'];$samstag = $this->zeiten->getSamstag();$samstag = json_decode($samstag['data'], true);$samstag['closed'] ? $samstagZeiten = [] : $samstagZeiten = $samstag['zeiten'];$sonntag = $this->zeiten->getSonntag();$sonntag = json_decode($sonntag['data'], true);$sonntag['closed'] ? $sonntagZeiten = [] : $sonntagZeiten = $sonntag['zeiten'];return ['open247' => $this->zeiten->isOpen247(),'extraInfo' => $this->zeiten->getInfo(),'montag' => ['bezeichnung' => $montag['bezeichnung'],'closed' => $montag['closed'],'zeiten' => $montagZeiten],'dienstag' => ['bezeichnung' => $dienstag['bezeichnung'],'closed' => $dienstag['closed'],'zeiten' => $dienstagZeiten],'mittwoch' => ['bezeichnung' => $mittwoch['bezeichnung'],'closed' => $mittwoch['closed'],'zeiten' => $mittwochZeiten],'donnerstag' => ['bezeichnung' => $donnerstag['bezeichnung'],'closed' => $donnerstag['closed'],'zeiten' => $donnerstagZeiten],'freitag' => ['bezeichnung' => $freitag['bezeichnung'],'closed' => $freitag['closed'],'zeiten' => $freitagZeiten],'samstag' => ['bezeichnung' => $samstag['bezeichnung'],'closed' => $samstag['closed'],'zeiten' => $samstagZeiten],'sonntag' => ['bezeichnung' => $sonntag['bezeichnung'],'closed' => $sonntag['closed'],'zeiten' => $sonntagZeiten],];}return [];}// #[Groups(['studio:read'])]public function getStudioGeo(): array{if ($this->geodaten) {$geoJson = $this->geodaten->getGeoJson();if ($geoJson) {$geoJson = json_decode($geoJson['data'], true);}$boundingBox = $this->geodaten->getBoundingBox();if ($boundingBox) {$boundingBox = json_decode($boundingBox['data'], true);}return ['id' => $this->geodaten->getId(),'osm_id' => $this->geodaten->getOsmId(),'place_id' => $this->geodaten->getPlaceId(),'display_name' => $this->geodaten->getDisplayName(),'importance' => $this->geodaten->getImportance(),'lon' => $this->geodaten->getGeoLon(),'lat' => $this->geodaten->getGeoLat(),'polygon' => $geoJson,'bounding_box' => $boundingBox,];}return [];}/*** @return Collection<int, News>*/public function getNews(): Collection{return $this->news;}public function addNews(News $news): self{if (!$this->news->contains($news)) {$this->news->add($news);$news->setStudio($this);}return $this;}public function removeNews(News $news): self{if ($this->news->removeElement($news)) {// set the owning side to null (unless already changed)if ($news->getStudio() === $this) {$news->setStudio(null);}}return $this;}public function setStudioContent(?StudioContent $studioContent): self{$this->studioContent = $studioContent;return $this;}public function getStudioContent(): ?StudioContent{return $this->studioContent;}// #[Groups(['studio:read','content:read'])]public function getStudioImpressum(): string{$impressum = $this->studioContent;$impressum->getImpressum();return $impressum->getImpressum();}public function getStudioKurse(): ?StudioKurse{return $this->studioKurse;}public function setStudioKurse(?StudioKurse $studioKurse): self{$this->studioKurse = $studioKurse;return $this;}public function getLeistungen(): array{return $this->leistungen;}public function setLeistungen(?array $leistungen): self{$this->leistungen = $leistungen;return $this;}#[Groups(['studio:read'])]public function getStudioLeistungen(): array{$request = Request::createFromGlobals();$selfUrl = $request->getSchemeAndHttpHost();$leistungArr = [];if ($this->getLeistungen()) {$leistungen = json_decode($this->leistungen['data'], true);$id = '';$title = '';$description = '';$color = '';$position = '';foreach ($leistungen as $tmp) {if(isset($tmp['category'])){$id = $tmp['category']['id'];$title = $tmp['category']['title'];$description = $tmp['category']['description'];$color = $tmp['category']['color'];$position = $tmp['category']['position'];}$item = ['id' => $tmp['id'],'url' => '/api/leistung/' . $tmp['id'],'title' => $tmp['title'] ?? '','description' => $tmp['description'] ?? '','preis' => $tmp['preis'] ?? '','position' => $tmp['position'] ?? '','inklusiv' => $tmp['inklusiv'] ?? '','sonstiges' => $tmp['sonstiges'] ?? '','icon_img' => $tmp['icon_img'] ?? '','icon_img_type' => $tmp['icon_img_type'] ?? '','leistung_img' => $tmp['leistung_img'] ?? '','leistung_img_type' => $tmp['leistung_img_type'] ?? '','category' => ['id' => $id,'title' => $title,'description' => $description,'color' => $color,'position' => $position,],];$leistungArr[] = $item;}}return ['self' => $selfUrl,'data' => $leistungArr];}#[Groups(['studio:read'])]public function getKurse(): ?array{if ($this->studioKurse) {$montag = json_decode($this->studioKurse->getMontag()['data'], true) ?? [];$dienstag = json_decode($this->studioKurse->getDienstag()['data'], true) ?? [];$mittwoch = json_decode($this->studioKurse->getMittwoch()['data'], true) ?? [];$donnerstag = json_decode($this->studioKurse->getDonnerstag()['data'], true) ?? [];$freitag = json_decode($this->studioKurse->getFreitag()['data'], true) ?? [];$samstag = json_decode($this->studioKurse->getSamstag()['data'], true) ?? [];$sonntag = json_decode($this->studioKurse->getSonntag()['data'], true) ?? [];return ['montag' => $montag,'dienstag' => $dienstag,'mittwoch' => $mittwoch,'donnerstag' => $donnerstag,'freitag' => $freitag,'samstag' => $samstag,'sonntag' => $sonntag];}return [];}}