events/Classes/Domain/Model/Event.php

620 lines
12 KiB
PHP
Raw Normal View History

<?php
namespace Wrm\Events\Domain\Model;
use TYPO3\CMS\Extbase\Annotation as Extbase;
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use Wrm\Events\Domain\Repository\DateRepository;
use Wrm\Events\Service\DataProcessingForModels;
class Event extends AbstractEntity
{
/**
* @var string
*/
protected $title = '';
2021-02-15 09:58:51 +01:00
/**
* @var string
*/
protected $subtitle = '';
/**
* @var string
*/
protected $globalId = '';
/**
* @var string
*/
protected $slug = '';
/**
* @var bool
*/
protected $highlight = false;
/**
* @var string
*/
protected $teaser = '';
/**
* @var string
*/
protected $details = '';
/**
* @var string
*/
protected $priceInfo = '';
2020-08-17 14:21:03 +02:00
/**
* @var string
*/
2022-08-02 15:56:18 +02:00
protected $web = '';
2020-08-17 14:21:03 +02:00
/**
* @var string
*/
2022-08-02 15:56:18 +02:00
protected $ticket = '';
/**
* @var string
*/
2022-08-02 15:56:18 +02:00
protected $facebook = '';
/**
* @var string
*/
2022-08-02 15:56:18 +02:00
protected $youtube = '';
/**
* @var string
*/
2022-08-02 15:56:18 +02:00
protected $instagram = '';
/**
2022-08-02 15:56:18 +02:00
* @var ObjectStorage<FileReference>
* @Extbase\ORM\Cascade remove
*/
2022-08-02 15:56:18 +02:00
protected $images;
2020-03-16 13:52:58 +01:00
/**
2022-08-02 15:56:18 +02:00
* @var ObjectStorage<Date>
* @Extbase\ORM\Cascade remove
* @Extbase\ORM\Lazy
2020-03-16 13:52:58 +01:00
*/
2022-08-02 15:56:18 +02:00
protected $dates;
2020-03-16 13:52:58 +01:00
/**
2022-08-02 15:56:18 +02:00
* @var Location|null
*/
2022-08-02 15:56:18 +02:00
protected $location = null;
/**
2022-08-02 15:56:18 +02:00
* @var Organizer|null
*/
2022-08-02 15:56:18 +02:00
protected $organizer = null;
/**
2022-08-02 15:56:18 +02:00
* @var Region|null
*/
2022-08-02 15:56:18 +02:00
protected $region = null;
/**
* @var string
*/
2022-08-02 15:56:18 +02:00
protected $pages = '';
2020-08-19 11:30:13 +02:00
/**
2022-08-02 15:56:18 +02:00
* @var ObjectStorage<Category>
2020-08-19 11:30:13 +02:00
*/
2022-08-02 15:56:18 +02:00
protected $categories;
2020-08-19 11:30:13 +02:00
/**
2022-08-02 15:56:18 +02:00
* @var ObjectStorage<Category>
*/
2022-08-02 15:56:18 +02:00
protected $features;
/**
2022-08-02 15:56:18 +02:00
* @var ObjectStorage<Partner>
*/
2022-08-02 15:56:18 +02:00
protected $partner;
/**
2022-08-02 15:56:18 +02:00
* @var ObjectStorage<Event>
*/
2022-08-02 15:56:18 +02:00
protected $referencesEvents;
/**
2022-08-02 15:56:18 +02:00
* @var int
*/
2022-08-02 15:56:18 +02:00
protected $_languageUid;
/**
2022-08-02 15:56:18 +02:00
* @var DataProcessingForModels
*/
2022-08-02 15:56:18 +02:00
protected $dataProcessing = null;
// Legacy location related info
/**
2022-08-02 15:56:18 +02:00
* @var string
*/
2022-08-02 15:56:18 +02:00
protected $name = '';
/**
* @var string
*/
2022-08-02 15:56:18 +02:00
protected $street = '';
/**
2022-08-02 15:56:18 +02:00
* @var string
*/
2022-08-02 15:56:18 +02:00
protected $district = '';
/**
2022-08-02 15:56:18 +02:00
* @var string
*/
2022-08-02 15:56:18 +02:00
protected $city = '';
/**
2022-08-02 15:56:18 +02:00
* @var string
*/
2022-08-02 15:56:18 +02:00
protected $zip = '';
/**
2022-08-02 15:56:18 +02:00
* @var string
*/
2022-08-02 15:56:18 +02:00
protected $country = '';
2020-10-01 08:34:13 +02:00
/**
2022-08-02 15:56:18 +02:00
* @var string
2020-10-01 08:34:13 +02:00
*/
2022-08-02 15:56:18 +02:00
protected $phone = '';
2020-10-01 08:34:13 +02:00
/**
2022-08-02 15:56:18 +02:00
* @var string
*/
2022-08-02 15:56:18 +02:00
protected $latitude = '';
/**
* @var string
*/
protected $longitude = '';
// End of legacy location info
public function __construct()
{
$this->initStorageObjects();
}
/**
* @param DataProcessingForModels $dataProcessing
*/
public function injectDataProcessingForModels(DataProcessingForModels $dataProcessing): void
{
$this->dataProcessing = $dataProcessing;
}
public function initializeObject(): void
{
$this->initStorageObjects();
}
protected function initStorageObjects(): void
{
$this->images = new ObjectStorage();
$this->dates = new ObjectStorage();
$this->categories = new ObjectStorage();
$this->features = new ObjectStorage();
$this->partner = new ObjectStorage();
$this->referencesEvents = new ObjectStorage();
}
public function getGlobalId(): string
{
return $this->globalId;
}
public function setGlobalId(string $globalId): void
{
$this->globalId = $globalId;
}
public function getTitle(): string
{
return $this->title;
}
public function setTitle(string $title): void
{
$this->title = $title;
}
public function getSubtitle(): string
2021-02-15 09:58:51 +01:00
{
return $this->subtitle;
}
public function setSubtitle(string $subtitle): void
2021-02-15 09:58:51 +01:00
{
$this->subtitle = $subtitle;
}
public function getTeaser(): string
{
return $this->teaser;
}
public function setTeaser(string $teaser): void
{
$this->teaser = $teaser;
}
public function getDetails(): string
{
return $this->details;
}
public function setDetails(string $details): void
{
$this->details = $details;
}
public function getPriceInfo(): string
{
return $this->priceInfo;
}
public function setPriceInfo(string $priceInfo): void
{
$this->priceInfo = $priceInfo;
}
public function getWeb(): string
{
return $this->web;
}
public function setWeb(string $web): void
{
$this->web = $web;
}
public function getTicket(): string
{
return $this->ticket;
}
public function setTicket(string $ticket): void
{
$this->ticket = $ticket;
}
public function getFacebook(): string
{
return $this->facebook;
}
public function setFacebook(string $facebook): void
{
$this->facebook = $facebook;
}
public function getYoutube(): string
{
return $this->youtube;
}
public function setYoutube(string $youtube): void
{
$this->youtube = $youtube;
}
public function getInstagram(): string
2020-08-19 11:30:13 +02:00
{
return $this->instagram;
}
public function setInstagram(string $instagram): void
2020-08-19 11:30:13 +02:00
{
$this->instagram = $instagram;
}
/**
2021-03-18 16:39:04 +01:00
* @return ObjectStorage<FileReference> $images
*/
2021-03-18 16:39:04 +01:00
public function getImages(): ObjectStorage
{
return $this->images;
}
/**
2021-03-18 16:39:04 +01:00
* @param ObjectStorage<FileReference> $images
*/
public function setImages(ObjectStorage $images): void
{
$this->images = $images;
}
public function getSlug(): string
{
return $this->slug;
}
public function setSlug(string $slug): void
{
$this->slug = $slug;
}
public function addDate(Date $date): void
{
$this->dates->attach($date);
}
public function removeDate(Date $date): void
{
$this->dates->detach($date);
}
/**
* @return ObjectStorage<Date>
*/
public function getDates(): ObjectStorage
{
return $this->dates;
}
/**
* @param ObjectStorage<Date> $dates
*/
public function setDates(ObjectStorage $dates): void
{
$this->dates = $dates;
}
/**
* @param ObjectStorage<Date> $dates
*/
public function removeAllDates(ObjectStorage $dates): void
{
$this->dates->removeAll($dates);
}
/**
* @return ObjectStorage<Partner>
*/
public function getPartner(): ObjectStorage
{
return $this->partner;
}
/**
* @return ObjectStorage<Event>
*/
public function getReferencesEvents(): ObjectStorage
{
return $this->referencesEvents;
}
2022-08-02 15:56:18 +02:00
public function setLocation(?Location $location): void
{
$this->location = $location;
// Keep this block as long as event still has the properties for legacy reasons.
// This ensures there is only a single point of truth, the new location object.
// That way we detect issues earlier and can migrate them until we get rid of the legacy code base.
if ($location instanceof Location) {
$this->name = '';
$this->street = '';
$this->district = '';
$this->city = '';
$this->zip = '';
$this->country = '';
$this->phone = '';
$this->latitude = '';
$this->longitude = '';
}
}
public function getLocation(): ?Location
{
return $this->location;
}
public function setOrganizer(Organizer $organizer): void
{
$this->organizer = $organizer;
}
public function getOrganizer(): ?Organizer
{
return $this->organizer;
}
public function getRegion(): ?Region
{
return $this->region;
}
public function setRegion(Region $region): void
{
$this->region = $region;
}
public function setHighlight(bool $highlight): void
{
$this->highlight = $highlight;
}
public function isHighlight(): bool
{
return $this->highlight;
}
public function getPages(): array
{
static $pages = null;
if (is_array($pages)) {
return $pages;
}
$pages = $this->dataProcessing->process($this);
return $pages;
}
public function addCategory(Category $category): void
{
$this->categories->attach($category);
}
/**
* @return array<Category>
*/
public function getCategories(): array
{
$categories = $this->categories->toArray();
usort($categories, function (Category $catA, Category $catB) {
return $catA->getSorting() <=> $catB->getSorting();
});
return $categories;
}
/**
* @param ObjectStorage<Category> $categories
*/
public function setCategories(ObjectStorage $categories): void
{
$this->categories = $categories;
}
2020-10-01 08:34:13 +02:00
/**
* @return array<Category>
*/
public function getFeatures(): array
{
$features = $this->features->toArray();
usort($features, function (Category $catA, Category $catB) {
return $catA->getSorting() <=> $catB->getSorting();
});
return $features;
}
/**
* @param ObjectStorage<Category> $features
*/
public function setFeatures(ObjectStorage $features): void
{
$this->features = $features;
}
public function setLanguageUid(int $languageUid): void
{
2020-10-01 08:56:44 +02:00
$this->_languageUid = $languageUid;
2020-10-01 08:34:13 +02:00
}
public function getLanguageUid(): int
{
2020-10-01 08:56:44 +02:00
return $this->_languageUid;
2020-10-01 08:34:13 +02:00
}
public function getLocalizedUid(): int
{
return $this->_localizedUid;
}
2022-08-02 15:56:18 +02:00
// Legacy location related info
public function getName(): string
{
if ($this->location instanceof Location) {
return $this->location->getName();
}
return $this->name;
}
public function getStreet(): string
{
if ($this->location instanceof Location) {
return $this->location->getStreet();
}
return $this->street;
}
public function getDistrict(): string
{
if ($this->location instanceof Location) {
return $this->location->getDistrict();
}
return $this->district;
}
public function getCountry(): string
{
if ($this->location instanceof Location) {
return $this->location->getCountry();
}
return $this->country;
}
public function getCity(): string
{
if ($this->location instanceof Location) {
return $this->location->getCity();
}
return $this->city;
}
public function getZip(): string
{
if ($this->location instanceof Location) {
return $this->location->getZip();
}
return $this->zip;
}
public function getPhone(): string
{
if ($this->location instanceof Location) {
return $this->location->getPhone();
}
return $this->phone;
}
public function getLatitude(): string
{
if ($this->location instanceof Location) {
return $this->location->getLatitude();
}
return $this->latitude;
}
public function getLongitude(): string
{
if ($this->location instanceof Location) {
return $this->location->getLongitude();
}
return $this->longitude;
}
}