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