Facebook
From bejke, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 150
  1. <?php
  2.  
  3. namespace AppEntity;
  4.  
  5. use AppRepositoryEventTranslationRepository;
  6. use DoctrineDBALTypesTypes;
  7. use DoctrineORMMapping as ORM;
  8.  
  9. #[ORMEntity(repositoryClass: EventTranslationRepository::class)]
  10. class EventTranslation
  11. {
  12.     #[ORMId]
  13.     #[ORMGeneratedValue]
  14.     #[ORMColumn]
  15.     private ?int $id = null;
  16.  
  17.     #[ORMColumn(length: 2, nullable: true)]
  18.     private ?string $locale = null;
  19.  
  20.     #[ORMColumn(length: 255, nullable: true)]
  21.     private ?string $title = null;
  22.  
  23.     #[ORMOneToOne(mappedBy: 'eventTranslationDe', targetEntity: Event::class, cascade: ['persist', 'remove'])]
  24.     private ?Event $eventDe;
  25.  
  26.     #[ORMOneToOne(mappedBy: 'eventTranslationEn', targetEntity: Event::class, cascade: ['persist', 'remove'])]
  27.     private ?Event $eventEn;
  28.  
  29.     #[ORMColumn(length: 255, nullable: true)]
  30.     private ?string $location = null;
  31.  
  32.     #[ORMColumn(type: Types::TEXT, nullable: true)]
  33.     private ?string $teaser = null;
  34.  
  35.     #[ORMColumn(length: 255, nullable: true)]
  36.     private ?string $registrationButtonText = null;
  37.  
  38.     #[ORMColumn(nullable: true)]
  39.     private ?int $eventsTemplate = null;
  40.  
  41.     #[ORMColumn(length: 255, nullable: true)]
  42.     private ?string $templateHeadline = null;
  43.  
  44.     #[ORMColumn(type: Types::TEXT, nullable: true)]
  45.     private ?string $templateAdditionalInfos = null;
  46.  
  47.     #[ORMColumn(type: Types::TEXT, nullable: true)]
  48.     private ?string $templateText = null;
  49.  
  50.     #[ORMColumn(type: Types::TEXT, nullable: true)]
  51.     private ?string $footerText = null;
  52.  
  53.     public function __toString(): string {
  54.         return $this->getTitle() !== null ? (string) $this->getTitle() : 'Event Translation Id: ' . $this->id;
  55.     }
  56.  
  57.     public function getId(): ?int
  58.     {
  59.         return $this->id;
  60.     }
  61.  
  62.     public function getLocale(): ?string
  63.     {
  64.         return $this->locale;
  65.     }
  66.  
  67.     public function setLocale(string $locale): static
  68.     {
  69.         $this->locale = $locale;
  70.  
  71.         return $this;
  72.     }
  73.  
  74.     public function getTitle(): ?string
  75.     {
  76.         return $this->title;
  77.     }
  78.  
  79.     public function setTitle(?string $title): static
  80.     {
  81.         $this->title = $title;
  82.  
  83.         return $this;
  84.     }
  85.  
  86.     public function getEventDe(): ?Event
  87.     {
  88.         return $this->eventDe;
  89.     }
  90.  
  91.     public function addEventDe(Event $eventDe): static
  92.     {
  93.         if (!$this->eventDe->contains($eventDe)) {
  94.             $this->eventDe->add($eventDe);
  95.             $eventDe->setEventTranslationDe($this);
  96.         }
  97.  
  98.         return $this;
  99.     }
  100.  
  101.     public function removeEventDe(Event $eventDe): static
  102.     {
  103.         if ($this->eventDe->removeElement($eventDe)) {
  104.             // set the owning side to null (unless already changed)
  105.             if ($eventDe->getEventTranslationDe() === $this) {
  106.                 $eventDe->setEventTranslationDe(null);
  107.             }
  108.         }
  109.  
  110.         return $this;
  111.     }
  112.  
  113.     public function getEventEn(): ?Event
  114.     {
  115.         return $this->eventEn;
  116.     }
  117.  
  118.     public function addEventEn(Event $eventEn): static
  119.     {
  120.         if (!$this->eventEn->contains($eventEn)) {
  121.             $this->eventEn->add($eventEn);
  122.             $eventEn->setEventTranslationEn($this);
  123.         }
  124.  
  125.         return $this;
  126.     }
  127.  
  128.     public function removeEventEn(Event $eventEn): static
  129.     {
  130.         if ($this->eventEn->removeElement($eventEn)) {
  131.             // set the owning side to null (unless already changed)
  132.             if ($eventEn->getEventTranslationEn() === $this) {
  133.                 $eventEn->setEventTranslationEn(null);
  134.             }
  135.         }
  136.  
  137.         return $this;
  138.     }
  139.  
  140.     public function getLocation(): ?string
  141.     {
  142.         return $this->location;
  143.     }
  144.  
  145.     public function setLocation(?string $location): static
  146.     {
  147.         $this->location = $location;
  148.  
  149.         return $this;
  150.     }
  151.  
  152.     public function getTeaser(): ?string
  153.     {
  154.         return $this->teaser;
  155.     }
  156.  
  157.     public function setTeaser(?string $teaser): static
  158.     {
  159.         $this->teaser = $teaser;
  160.  
  161.         return $this;
  162.     }
  163.  
  164.     public function getRegistrationButtonText(): ?string
  165.     {
  166.         return $this->registrationButtonText;
  167.     }
  168.  
  169.     public function setRegistrationButtonText(?string $registrationButtonText): static
  170.     {
  171.         $this->registrationButtonText = $registrationButtonText;
  172.  
  173.         return $this;
  174.     }
  175.  
  176.     public function toArray(): array {
  177.         return [
  178.             'title' => $this->getTitle(),
  179.             'location' => $this->getLocation(),
  180.             'buttonText' => $this->getRegistrationButtonText(),
  181.             'teaser' => $this->getTeaser(),
  182.             'templateHeadline' => $this->getTemplateHeadline(),
  183.             'templateAdditionalInofs' => $this->getTemplateAdditionalInfos(),
  184.             'templateText' => $this->getTemplateText(),
  185.             'templateFooterText' => $this->getFooterText(),
  186.         ];
  187.     }
  188.  
  189.     public function getEventsTemplate(): ?int
  190.     {
  191.         return $this->eventsTemplate;
  192.     }
  193.  
  194.     public function setEventsTemplate(?int $eventsTemplate): static
  195.     {
  196.         $this->eventsTemplate = $eventsTemplate;
  197.  
  198.         return $this;
  199.     }
  200.  
  201.     public function getTemplateHeadline(): ?string
  202.     {
  203.         return $this->templateHeadline;
  204.     }
  205.  
  206.     public function setTemplateHeadline(?string $templateHeadline): static
  207.     {
  208.         $this->templateHeadline = $templateHeadline;
  209.  
  210.         return $this;
  211.     }
  212.  
  213.     public function getTemplateAdditionalInfos(): ?string
  214.     {
  215.         return $this->templateAdditionalInfos;
  216.     }
  217.  
  218.     public function setTemplateAdditionalInfos(?string $templateAdditionalInfos): static
  219.     {
  220.         $this->templateAdditionalInfos = $templateAdditionalInfos;
  221.  
  222.         return $this;
  223.     }
  224.  
  225.     public function getTemplateText(): ?string
  226.     {
  227.         return $this->templateText;
  228.     }
  229.  
  230.     public function setTemplateText(?string $templateText): static
  231.     {
  232.         $this->templateText = $templateText;
  233.  
  234.         return $this;
  235.     }
  236.  
  237.     public function getFooterText(): ?string
  238.     {
  239.         return $this->footerText;
  240.     }
  241.  
  242.     public function setFooterText(?string $footerText): static
  243.     {
  244.         $this->footerText = $footerText;
  245.  
  246.         return $this;
  247.     }
  248. }
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257. <?php
  258.  
  259. namespace AppEntity;
  260.  
  261. use AppEventListenerEventEntityListener;
  262. use AppRepositoryEventRepository;
  263. use DateTime;
  264. use DateTimeImmutable;
  265. use DateTimeInterface;
  266. use DoctrineCommonCollectionsArrayCollection;
  267. use DoctrineCommonCollectionsCollection;
  268. use DoctrineDBALTypesTypes;
  269. use DoctrineORMEntityManagerInterface;
  270. use DoctrineORMMapping as ORM;
  271. use SymfonyComponentSecurityCoreAuthenticationTokenStorageTokenStorageInterface;
  272.  
  273. #[ORMEntity(repositoryClass: EventRepository::class)]
  274. #[ORMEntityListeners([EventEntityListener::class])]
  275. class Event
  276. {
  277.     #[ORMId]
  278.     #[ORMGeneratedValue]
  279.     #[ORMColumn]
  280.     private ?int $id = null;
  281.  
  282.     #[ORMColumn(length: 255, nullable: true)]
  283.     #[AssertFile(mimeTypes: 'image/jpeg, image/jpg', mimeTypesMessage: 'Please upload a valid image (JPEG or JPG Format)', disallowEmptyMessage: 'Please select an image file.')]
  284.     private ?string $image = null;
  285.  
  286.     #[ORMColumn(type: Types::DATE_MUTABLE)]
  287.     private ?DateTimeInterface $startDate = null;
  288.  
  289.     #[ORMOneToOne(inversedBy: 'eventDe', cascade: ['persist', 'remove'])]
  290.     #[ORMJoinColumn(nullable: false)]
  291.     private ?EventTranslation $eventTranslationDe = null;
  292.  
  293.     #[ORMOneToOne(inversedBy: 'eventEn', cascade: ['persist', 'remove'])]
  294.     #[ORMJoinColumn(nullable: false)]
  295.     private ?EventTranslation $eventTranslationEn = null;
  296.  
  297.     #[ORMColumn(type: Types::DATE_MUTABLE, nullable: true)]
  298.     private ?DateTimeInterface $endDate = null;
  299.  
  300.     #[ORMColumn(type: Types::DATE_MUTABLE, nullable: true)]
  301.     private ?DateTimeInterface $dateSignUpClose = null;
  302.  
  303.     #[ORMColumn(nullable: true)]
  304.     private ?float $itemNr = null;
  305.  
  306.     #[ORMManyToMany(targetEntity: Category::class, inversedBy: 'events', fetch: 'EAGER')]
  307.     private Collection $categories;
  308.  
  309.     #[ORMColumn(nullable: true)]
  310.     private ?int $maxDrivers = null;
  311.  
  312.     #[ORMColumn(nullable: true)]
  313.     private ?int $availableBreakpoint = null;
  314.  
  315.     #[ORMColumn(type: Types::DATETIME_MUTABLE)]
  316.     private ?DateTimeInterface $lastModified = null;
  317.  
  318.     #[ORMColumn(length: 255, nullable: true)]
  319.     private ?string $lastModifiedBy = null;
  320.  
  321.     #[ORMColumn(nullable: true)]
  322.     private ?int $bookingStatus = null;
  323.  
  324.     #[ORMManyToOne(inversedBy: 'events')]
  325.     private ?Organiser $organiser = null;
  326.  
  327.     #[ORMColumn(nullable: true)]
  328.     private ?int $template = null;
  329.  
  330.     #[ORMOneToMany(mappedBy: 'event', targetEntity: ImageSlider::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
  331.     private Collection $templateImageSlider;
  332.  
  333.     #[ORMOneToMany(mappedBy: 'event', targetEntity: EventVarietyCollection::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
  334.     private Collection $eventVarietyCollection;
  335.  
  336.     #[ORMColumn(nullable: true)]
  337.     private ?int $travelType = null;
  338.  
  339.     #[ORMColumn(nullable: true)]
  340.     private ?int $status = null;
  341.  
  342.     #[ORMOneToMany(mappedBy: 'event', targetEntity: Booking::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
  343.     private Collection $booking;
  344.  
  345.     public function __construct()
  346.     {
  347.         $this->categories = new ArrayCollection();
  348.         $this->templateImageSlider = new ArrayCollection();
  349.         $this->eventVarietyCollection = new ArrayCollection();
  350.         $this->booking = new ArrayCollection();
  351.     }
  352.  
  353.     public function getId(): ?int
  354.     {
  355.         return $this->id;
  356.     }
  357.  
  358.     public function getImage(): ?string
  359.     {
  360.         return $this->image;
  361.     }
  362.  
  363.     public function setImage(?string $image): static
  364.     {
  365.         $this->image = $image;
  366.  
  367.         return $this;
  368.     }
  369.  
  370.     public function getStartDate(): ?DateTimeInterface
  371.     {
  372.         return $this->startDate;
  373.     }
  374.  
  375.     public function setStartDate(DateTimeInterface $startDate): static
  376.     {
  377.         $this->startDate = $startDate;
  378.  
  379.         return $this;
  380.     }
  381.  
  382.     public function getEventTranslationDe(): ?EventTranslation
  383.     {
  384.         return $this->eventTranslationDe;
  385.     }
  386.  
  387.     public function setEventTranslationDe(?EventTranslation $eventTranslationDe): static
  388.     {
  389.         $this->eventTranslationDe = $eventTranslationDe;
  390.         $this->eventTranslationDe->setLocale('de');
  391.  
  392.         return $this;
  393.     }
  394.  
  395.     public function getEventTranslationEn(): ?EventTranslation
  396.     {
  397.         return $this->eventTranslationEn;
  398.     }
  399.  
  400.     public function setEventTranslationEn(?EventTranslation $eventTranslationEn): static
  401.     {
  402.         $this->eventTranslationEn = $eventTranslationEn;
  403.         $this->eventTranslationEn->setLocale('en');
  404.  
  405.         return $this;
  406.     }
  407.  
  408.     public function getEndDate(): ?DateTimeInterface
  409.     {
  410.         return $this->endDate;
  411.     }
  412.  
  413.     public function setEndDate(?DateTimeInterface $endDate): static
  414.     {
  415.         $this->endDate = $endDate;
  416.  
  417.         return $this;
  418.     }
  419.  
  420.     public function getDateSignUpClose(): ?DateTimeInterface
  421.     {
  422.         return $this->dateSignUpClose;
  423.     }
  424.  
  425.     public function setDateSignUpClose(?DateTimeInterface $dateSignUpClose): static
  426.     {
  427.         $this->dateSignUpClose = $dateSignUpClose;
  428.  
  429.         return $this;
  430.     }
  431.  
  432.     public function getItemNr(): ?float
  433.     {
  434.         return $this->itemNr;
  435.     }
  436.  
  437.     public function setItemNr(?float $itemNr): static
  438.     {
  439.         $this->itemNr = $itemNr;
  440.  
  441.         return $this;
  442.     }
  443.  
  444.     /**
  445.      * @return Collection<int, Category>
  446.      */
  447.     public function getCategories(): Collection
  448.     {
  449.         return $this->categories;
  450.     }
  451.  
  452.     public function addCategory(Category $category): static
  453.     {
  454.         if (!$this->categories->contains($category)) {
  455.             $this->categories->add($category);
  456.         }
  457.  
  458.         return $this;
  459.     }
  460.  
  461.     public function removeCategory(Category $category): static
  462.     {
  463.         $this->categories->removeElement($category);
  464.  
  465.         return $this;
  466.     }
  467.  
  468.     public function getMaxDrivers(): ?int
  469.     {
  470.         return $this->maxDrivers;
  471.     }
  472.  
  473.     public function setMaxDrivers(?int $maxDrivers): static
  474.     {
  475.         $this->maxDrivers = $maxDrivers;
  476.  
  477.         return $this;
  478.     }
  479.  
  480.     public function getAvailableBreakpoint(): ?int
  481.     {
  482.         return $this->availableBreakpoint;
  483.     }
  484.  
  485.     public function setAvailableBreakpoint(?int $availableBreakpoint): static
  486.     {
  487.         $this->availableBreakpoint = $availableBreakpoint;
  488.  
  489.         return $this;
  490.     }
  491.  
  492.     public function getLastModified(): ?DateTimeInterface
  493.     {
  494.         return $this->lastModified;
  495.     }
  496.  
  497.     public function setLastModified(): static
  498.     {
  499.         date_default_timezone_set('Europe/Berlin');
  500.         $this->lastModified = new DateTimeImmutable('now');
  501.         return $this;
  502.     }
  503.  
  504.     public function getEventTranslation(string $locale = 'en'): array
  505.     {
  506.         return $locale === 'de' ? $this->getEventTranslationDe()->toArray() : $this->getEventTranslationEn()->toArray();
  507.     }
  508.  
  509.     public function getCategoriesArray($locale): array
  510.     {
  511.         $categories = $this->getCategories()->toArray();
  512.         return array_map(fn($category) => $category->toArray($locale), $categories);
  513.     }
  514.  
  515.     public function getBookingStatus(): ?int
  516.     {
  517. //      if bookingStatus is not customised set to 'Preview'
  518.         if ($this->bookingStatus == null) {
  519.             $this->bookingStatus = 0;
  520.         }
  521.         return $this->bookingStatus;
  522.     }
  523.  
  524.     public function setBookingStatus(int $bookingStatus): static
  525.     {
  526.         $this->bookingStatus = $bookingStatus;
  527.         return $this;
  528.     }
  529.  
  530.     public function getOrganiser(): ?Organiser
  531.     {
  532.         return $this->organiser;
  533.     }
  534.  
  535.     public function setOrganiser(?Organiser $organiser): static
  536.     {
  537.         $this->organiser = $organiser;
  538.         return $this;
  539.     }
  540.  
  541.     public function getBookingStatusString($locale): ?string
  542.     {
  543.         if ($locale == 'en') {
  544.             $bookingStatusArray = ['Preview', 'Available', 'Not Available', 'Review', 'On Request'];
  545.         } else {
  546.             $bookingStatusArray = ['Vorschau', 'Verfügbar', 'Nicht mehr verfügbar', 'Rückblick', 'Auf Anfrage'];
  547.         }
  548.  
  549.         return $bookingStatusArray[$this->getBookingStatus()] ?? null;
  550.     }
  551.  
  552.     public function getTravelTypeString(): ?string
  553.     {
  554.         $bookingStatusArray = ['none', 'packageTravel'];
  555.         return $bookingStatusArray[$this->getTravelType()] ?? null;
  556.     }
  557.  
  558.     public function getStatusString(): ?string
  559.     {
  560.         $statusArray = ['draft', 'live'];
  561.         return $statusArray[$this->getStatus()] ?? null;
  562.     }
  563.  
  564.     public function getSliderImages($entityManager): array
  565.     {
  566.         $imageSliderEntities = $entityManager->getRepository(ImageSlider::class)->findBy(['event' => $this->getId()]);
  567.         $sliderImages = [];
  568.  
  569.         foreach ($imageSliderEntities as $imageSliderEntity) {
  570.             $sliderImages[] = '/uploads/images/event/slider/' . $imageSliderEntity->getImage();
  571.         }
  572.  
  573.         return $sliderImages;
  574.     }
  575.  
  576.     private function mapVarietyDataContent($entityManager, $varietyCollection): array
  577.     {
  578.         $formFields = [];
  579.         $varietyCollectionFormFields = $entityManager->getRepository(VarietyCollectionFormField::class)
  580.             ->findBy(['varietyCollection' => $varietyCollection->getId()]);
  581.  
  582.         foreach ($varietyCollectionFormFields as $varietyCollectionFormField) {
  583.             $formFields[] = [
  584.                 'id' => $varietyCollectionFormField->getId(),
  585.                 'inputType' => $varietyCollectionFormField->getInputType(),
  586.                 'label' => $varietyCollectionFormField->getLabel(),
  587.                 'isRequired' => $varietyCollectionFormField->isIsRequired(),
  588.             ];
  589.         }
  590.  
  591.         return [
  592.             'id' => $varietyCollection->getId(),
  593.             'textTop' => $varietyCollection->getTextTop(),
  594.             'textBottom' => $varietyCollection->getTextBottom(),
  595.             'halfWidth' => $varietyCollection->isHalfWidth(),
  596.             'formFields' => $formFields,
  597.         ];
  598.     }
  599.  
  600.     private function mapVarietyData($variety, $entityManager): array
  601.     {
  602.         $varietyContent = [];
  603.         if ($variety) {
  604.             $varietyCollections = $entityManager->getRepository(VarietyCollection::class)
  605.                 ->findBy(['variety' => $variety->getId()]);
  606.  
  607.             foreach ($varietyCollections as $varietyCollection) {
  608.                 $varietyContent[] = $this->mapVarietyDataContent($entityManager, $varietyCollection);
  609.             }
  610.  
  611.             return [
  612.                 'id' => $variety->getId(),
  613.                 'neededSeats' => $variety->getNeededSeats(),
  614.                 'title' => $variety->getTitle(),
  615.                 'varietyContent' => $varietyContent,
  616.             ];
  617.         }
  618.  
  619.         return [];
  620.     }
  621.  
  622.     public function getFormattedPrice($price, $locale)
  623.     {
  624.         $dotPosition = strpos($price, '.');
  625.         $commaPosition = strpos($price, ',');
  626.  
  627.         if ($dotPosition && $commaPosition) {
  628.             if (($dotPosition < $commaPosition && $locale == 'en') || ($dotPosition >= $commaPosition && $locale == 'de')) {
  629.                 $formattedNumber = str_replace('.', '|', $price);
  630.                 $formattedNumber = str_replace(',', '.', $formattedNumber);
  631.                 return str_replace('|', ',', $formattedNumber);
  632.             } else {
  633.                 return $price;
  634.             }
  635.         } else {
  636.             if ($dotPosition && $locale != 'en') {
  637.                 return str_replace('.', ',', $price);
  638.             }
  639.  
  640.             if ($commaPosition && $locale == 'en') {
  641.                 return str_replace(',', '.', $price);
  642.             }
  643.  
  644.             return $price;
  645.         }
  646.     }
  647.  
  648.     public function getEventsVarieties($entityManager, $locale): array
  649.     {
  650.         $eventVarietyCollections = $entityManager->getRepository(EventVarietyCollection::class)
  651.             ->findBy(['event' => $this->getId()]);
  652.         $varieties = [];
  653.         $accompanyingPersonVarieties = [];
  654.  
  655.         foreach ($eventVarietyCollections as $eventVarietyCollection) {
  656.             $tempArray = [
  657.                 'id' => $eventVarietyCollection->getId(),
  658.                 'variety' => $this->mapVarietyData($eventVarietyCollection->getVariety(), $entityManager),
  659.                 'price' => $this->getFormattedPrice($eventVarietyCollection->getPrice(), $locale),
  660.                 'maximumSelectableAmount' => $eventVarietyCollection->getMaximumSelectableAmount()
  661.             ];
  662.  
  663.             // sort for varieties and accompaningVarieties
  664.             $eventVarietyCollection->isIsAccompanyingPersonVariety() ?
  665.                 $accompanyingPersonVarieties[] = $tempArray : $varieties[] = $tempArray;
  666.         }
  667.  
  668.         return ['eventsVarieties' => $varieties, 'eventsAccompanyingPersonVarieties' => $accompanyingPersonVarieties];
  669.     }
  670.  
  671.     private function getSlugOfTitle($title): string
  672.     {
  673.         //remove spacen and / and make strin lowercase only
  674.         return strtolower(preg_replace('/s+/ ', '-', $title));
  675.     }
  676.  
  677.     public function toArray(EntityManagerInterface $entityManager, string $locale = 'en', bool $isDetail = false): array
  678.     {
  679.         $translation = $this->getEventTranslation($locale);
  680.         $image = $this->getImage() != null ? '/uploads/images/event/' . $this->getImage() : null;
  681.  
  682.         $array = [
  683.             'id' => $this->getId(),
  684.             'title' => $translation['title'],
  685.             'slug' => $this->getSlugOfTitle($translation['title']),
  686.             'itemNr' => $this->getItemNr(),
  687.             'date' => $this->getStartDate(),
  688.             'endDate' => $this->getEndDate(),
  689.             'categories' => $this->getCategoriesArray($locale),
  690.             'image' => $image,
  691.             'location' => $translation['location'],
  692.             'buttonText' => $translation['buttonText'],
  693.             'travelType' => $this->getTravelTypeString(),
  694.             'status' => $this->getStatusString(),
  695.             'type' => $this->getBookingStatusString($locale),
  696.         ];
  697.  
  698.         if ($this->getOrganiser()) {
  699.             $array['organiser'] = $this->getOrganiser()->toArray($locale);
  700.         } else {
  701.             $array['organiser'] = null;
  702.         }
  703.  
  704.         if ($isDetail) {
  705.             $currentDate = new DateTime(); // Get the current date and time
  706.             $currentDate->setTime(0, 0, 0);
  707.  
  708.             $varieties = $this->getEventsVarieties($entityManager, $locale);
  709.             $array['teaser'] = $translation['teaser'];
  710.             $array['maximumSeatAmount'] = $this->getMaxDrivers();
  711.             $array['availabilityBreakpoint'] = $this->getAvailableBreakpoint();
  712.             if ($this->getStartDate() >= $currentDate) {
  713.                 $array['availableSeats'] = $this->getAvailableSeats();
  714.             } else {
  715.                 $array['availableSeats'] = 0;
  716.             }
  717.             $array['sliderImages'] = $this->getSliderImages($entityManager);
  718.             $array['templateHeadline'] = $translation['templateHeadline'];
  719.             $array['templateAdditionalInofs'] = $translation['templateAdditionalInofs'];
  720.             $array['templateText'] = $translation['templateText'];
  721.             $array['templateFooterText'] = $translation['templateFooterText'];
  722.             $array['eventsVarieties'] = $varieties['eventsVarieties'];
  723.             $array['eventsAccompanyingPersonVarieties'] = $varieties['eventsAccompanyingPersonVarieties'];
  724.         }
  725.  
  726.         return $array;
  727.     }
  728.  
  729.     public function getTemplate(): ?int
  730.     {
  731.         return $this->template;
  732.     }
  733.  
  734.     public function setTemplate(?int $template): static
  735.     {
  736.         $this->template = $template;
  737.  
  738.         return $this;
  739.     }
  740.  
  741.     /**
  742.      * @return Collection<int, ImageSlider>
  743.      */
  744.     public function getTemplateImageSlider(): Collection
  745.     {
  746.         return $this->templateImageSlider;
  747.     }
  748.  
  749.     public function addTemplateImageSlider(ImageSlider $templateImageSlider): static
  750.     {
  751.         if (!$this->templateImageSlider->contains($templateImageSlider)) {
  752.             $this->templateImageSlider->add($templateImageSlider);
  753.             $templateImageSlider->setEvent($this);
  754.         }
  755.  
  756.         return $this;
  757.     }
  758.  
  759.     public function removeTemplateImageSlider(ImageSlider $templateImageSlider): static
  760.     {
  761.         if ($this->templateImageSlider->removeElement($templateImageSlider)) {
  762.             // set the owning side to null (unless already changed)
  763.             if ($templateImageSlider->getEvent() === $this) {
  764.                 $templateImageSlider->setEvent(null);
  765.             }
  766.         }
  767.  
  768.         return $this;
  769.     }
  770.  
  771.     /**
  772.      * @return Collection<int, EventVarietyCollection>
  773.      */
  774.     public function getEventVarietyCollection(): Collection
  775.     {
  776.         return $this->eventVarietyCollection;
  777.     }
  778.  
  779.     public function addEventVarietyCollection(EventVarietyCollection $eventVarietyCollection): static
  780.     {
  781.         if (!$this->eventVarietyCollection->contains($eventVarietyCollection)) {
  782.             $this->eventVarietyCollection->add($eventVarietyCollection);
  783.             $eventVarietyCollection->setEvent($this);
  784.         }
  785.  
  786.         return $this;
  787.     }
  788.  
  789.     public function removeEventVarietyCollection(EventVarietyCollection $eventVarietyCollection): static
  790.     {
  791.         if ($this->eventVarietyCollection->removeElement($eventVarietyCollection)) {
  792.             // set the owning side to null (unless already changed)
  793.             if ($eventVarietyCollection->getEvent() === $this) {
  794.                 $eventVarietyCollection->setEvent(null);
  795.             }
  796.         }
  797.  
  798.         return $this;
  799.     }
  800.  
  801.     public function getTravelType(): ?int
  802.     {
  803. //      if travelType is not customised set to 'none'
  804.         if ($this->travelType == null) {
  805.             $this->travelType = 0;
  806.         }
  807.  
  808.         return $this->travelType;
  809.     }
  810.  
  811.     public function setTravelType(?int $travelType): static
  812.     {
  813.         $this->travelType = $travelType;
  814.         return $this;
  815.     }
  816.  
  817.     public function getStatus(): ?int
  818.     {
  819. //      if status is not customised set to 'none'
  820.         if ($this->status == null) {
  821.             $this->status = 0;
  822.         }
  823.  
  824.         return $this->status;
  825.     }
  826.  
  827.     public function setStatus(?int $status): static
  828.     {
  829.         $this->status = $status;
  830.         return $this;
  831.     }
  832.  
  833.     public function getBookedBlockedSeats(): int
  834.     {
  835.         $bookings = $this->getBooking();
  836.         $totalCalculatedSeatAmount = 0;
  837.  
  838.         foreach ($bookings as $booking) {
  839.             $totalCalculatedSeatAmount += $booking->getCalculatedSeatAmount();
  840.         }
  841.  
  842.         return $totalCalculatedSeatAmount;
  843.     }
  844.  
  845.     public function getTemporaryBlockedSeats(): int
  846.     {
  847.         // müsste bei hinzufügen zum Warenkorb noch berechnet werden und beim löschen aus dem Warenkorb wieder abgezogen werden
  848.         return 0;
  849.     }
  850.  
  851.     public function getBookableBlocked(): string
  852.     {
  853.         $blocked = $this->getBookedBlockedSeats();
  854.         $bookable = $this->maxDrivers;
  855.         return $bookable . '/' . $blocked;
  856.     }
  857.  
  858.     public function getAvailableSeats(): int
  859.     {
  860.         $blocked = $this->getBookedBlockedSeats();
  861.         $bookable = $this->maxDrivers;
  862.         $temporaryBlocked = $this->getTemporaryBlockedSeats();
  863.         return $bookable - $blocked - $temporaryBlocked;
  864.     }
  865.  
  866.     /**
  867.      * @return Collection<int, Booking>
  868.      */
  869.     public function getBooking(): Collection
  870.     {
  871.         return $this->booking;
  872.     }
  873.  
  874.     public function addBooking(Booking $booking): static
  875.     {
  876.         if (!$this->booking->contains($booking)) {
  877.             $this->booking->add($booking);
  878.             $booking->setEvent($this);
  879.         }
  880.  
  881.         return $this;
  882.     }
  883.  
  884.     public function removeBooking(Booking $booking): static
  885.     {
  886.         if ($this->booking->removeElement($booking)) {
  887.             // set the owning side to null (unless already changed)
  888.             if ($booking->getEvent() === $this) {
  889.                 $booking->setEvent(null);
  890.             }
  891.         }
  892.  
  893.         return $this;
  894.     }
  895.  
  896.     public function getLastModifiedBy(): ?string
  897.     {
  898.         return $this->lastModifiedBy;
  899.     }
  900.  
  901.     public function setLastModifiedBy(TokenStorageInterface $tokenStorage): static    {
  902.         $user = $tokenStorage->getToken()->getUser();
  903.         $this->lastModifiedBy = $user->getEmail();
  904.         return $this;
  905.     }
  906. }
  907.