2021-08-18 13:54:18 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 Daniel Siepmann <coding@daniel-siepmann.de>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace WerkraumMedia\ThueCat\Domain\Model\Frontend;
|
|
|
|
|
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
|
|
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
|
|
|
|
|
|
|
|
abstract class Place extends Base
|
|
|
|
{
|
2023-12-04 15:37:57 +01:00
|
|
|
protected ?Address $address = null;
|
2021-08-18 13:54:18 +02:00
|
|
|
|
2023-12-04 15:19:20 +01:00
|
|
|
protected string $url = '';
|
2022-11-29 11:50:22 +01:00
|
|
|
|
2023-12-04 15:37:57 +01:00
|
|
|
protected ?OpeningHours $openingHours = null;
|
2021-08-18 13:54:18 +02:00
|
|
|
|
2023-12-04 15:37:57 +01:00
|
|
|
protected ?OpeningHours $specialOpeningHours = null;
|
2022-11-28 11:06:54 +01:00
|
|
|
|
2021-08-18 13:54:18 +02:00
|
|
|
/**
|
|
|
|
* @var ObjectStorage<ParkingFacility>
|
|
|
|
*/
|
2023-12-04 15:19:20 +01:00
|
|
|
protected ObjectStorage $parkingFacilityNearBy;
|
2021-08-18 13:54:18 +02:00
|
|
|
|
2023-12-05 08:55:20 +01:00
|
|
|
/**
|
|
|
|
* Necessary for Extbase/Symfony.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2023-12-04 15:19:20 +01:00
|
|
|
protected string $sanitation = '';
|
2021-08-18 13:54:18 +02:00
|
|
|
|
2023-12-04 15:19:20 +01:00
|
|
|
protected string $otherService = '';
|
2021-08-18 13:54:18 +02:00
|
|
|
|
2023-12-04 15:19:20 +01:00
|
|
|
protected string $trafficInfrastructure = '';
|
2021-08-18 13:54:18 +02:00
|
|
|
|
2023-12-05 08:55:20 +01:00
|
|
|
/**
|
|
|
|
* Necessary for Extbase/Symfony.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2023-12-04 15:19:20 +01:00
|
|
|
protected string $paymentAccepted = '';
|
2021-08-18 13:54:18 +02:00
|
|
|
|
2023-12-05 08:55:20 +01:00
|
|
|
/**
|
|
|
|
* Necessary for Extbase/Symfony.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2023-12-04 15:19:20 +01:00
|
|
|
protected string $distanceToPublicTransport = '';
|
2021-08-18 13:54:18 +02:00
|
|
|
|
2023-12-04 15:37:57 +01:00
|
|
|
protected ?AccessiblitySpecification $accessibilitySpecification = null;
|
2021-08-23 14:20:36 +02:00
|
|
|
|
2021-08-18 13:54:18 +02:00
|
|
|
public function initializeObject(): void
|
|
|
|
{
|
|
|
|
$this->parkingFacilityNearBy = new ObjectStorage();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAddress(): ?Address
|
|
|
|
{
|
|
|
|
return $this->address;
|
|
|
|
}
|
|
|
|
|
2022-11-29 11:50:22 +01:00
|
|
|
public function getUrl(): string
|
|
|
|
{
|
|
|
|
return $this->url;
|
|
|
|
}
|
|
|
|
|
2021-08-18 13:54:18 +02:00
|
|
|
public function getOpeningHours(): ?OpeningHours
|
|
|
|
{
|
|
|
|
return $this->openingHours;
|
|
|
|
}
|
|
|
|
|
2023-01-05 10:30:23 +01:00
|
|
|
public function getMergedOpeningHours(): ?MergedOpeningHours
|
|
|
|
{
|
|
|
|
if ($this->openingHours === null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return $this->openingHours->getMerged();
|
|
|
|
}
|
|
|
|
|
2022-11-28 11:06:54 +01:00
|
|
|
public function getSpecialOpeningHours(): ?OpeningHours
|
|
|
|
{
|
|
|
|
return $this->specialOpeningHours;
|
|
|
|
}
|
|
|
|
|
2023-01-05 10:30:23 +01:00
|
|
|
public function getMergedSpecialOpeningHours(): ?MergedOpeningHours
|
|
|
|
{
|
|
|
|
if ($this->specialOpeningHours === null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return $this->specialOpeningHours->getMerged();
|
|
|
|
}
|
|
|
|
|
2021-08-18 13:54:18 +02:00
|
|
|
public function getParkingFacilitiesNearBy(): ObjectStorage
|
|
|
|
{
|
|
|
|
return $this->parkingFacilityNearBy;
|
|
|
|
}
|
|
|
|
|
2022-12-12 13:35:16 +01:00
|
|
|
public function getParkingFacilitiesNearBySortedByAlphabet(): array
|
|
|
|
{
|
|
|
|
$facilities = $this->parkingFacilityNearBy->toArray();
|
|
|
|
usort($facilities, function (ParkingFacility $a, ParkingFacility $b) {
|
|
|
|
return $a->getTitle() <=> $b->getTitle();
|
|
|
|
});
|
|
|
|
|
|
|
|
return $facilities;
|
|
|
|
}
|
|
|
|
|
2021-08-18 13:54:18 +02:00
|
|
|
public function getSanitation(): array
|
|
|
|
{
|
|
|
|
return GeneralUtility::trimExplode(',', $this->sanitation, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getOtherServices(): array
|
|
|
|
{
|
|
|
|
return GeneralUtility::trimExplode(',', $this->otherService, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTrafficInfrastructures(): array
|
|
|
|
{
|
|
|
|
return GeneralUtility::trimExplode(',', $this->trafficInfrastructure, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPaymentAccepted(): array
|
|
|
|
{
|
|
|
|
return GeneralUtility::trimExplode(',', $this->paymentAccepted, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDistanceToPublicTransport(): array
|
|
|
|
{
|
2022-12-12 13:51:08 +01:00
|
|
|
$values = GeneralUtility::trimExplode(':', $this->distanceToPublicTransport, true, 3);
|
2021-08-18 13:54:18 +02:00
|
|
|
if ($values === []) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
return [
|
|
|
|
'value' => $values[0] ?? '',
|
|
|
|
'unit' => $values[1] ?? '',
|
2022-12-12 13:51:08 +01:00
|
|
|
'types' => GeneralUtility::trimExplode(':', $values[2] ?? '', true),
|
2021-08-18 13:54:18 +02:00
|
|
|
];
|
|
|
|
}
|
2021-08-23 14:20:36 +02:00
|
|
|
|
|
|
|
public function getAccessibilitySpecification(): ?AccessiblitySpecification
|
|
|
|
{
|
|
|
|
return $this->accessibilitySpecification;
|
|
|
|
}
|
2021-08-18 13:54:18 +02:00
|
|
|
}
|