2019-07-18 13:44:19 +02:00
|
|
|
<?php
|
2021-01-07 08:50:43 +01:00
|
|
|
|
2019-07-18 13:44:19 +02:00
|
|
|
namespace Wrm\Events\Domain\Model;
|
|
|
|
|
2021-01-07 08:47:15 +01:00
|
|
|
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
|
2021-01-07 08:50:43 +01:00
|
|
|
|
2019-07-18 13:44:19 +02:00
|
|
|
/**
|
|
|
|
* Date
|
|
|
|
*/
|
2021-01-07 08:47:15 +01:00
|
|
|
class Date extends AbstractEntity
|
2019-07-18 13:44:19 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \DateTime
|
|
|
|
*/
|
|
|
|
protected $start = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var \DateTime
|
|
|
|
*/
|
2019-08-14 17:22:01 +02:00
|
|
|
protected $end = null;
|
2019-07-18 13:44:19 +02:00
|
|
|
|
2021-01-12 16:42:58 +01:00
|
|
|
/**
|
2021-03-11 17:39:15 +01:00
|
|
|
* @var string
|
2021-01-12 16:42:58 +01:00
|
|
|
*/
|
2021-03-11 17:39:15 +01:00
|
|
|
protected $canceled = "no";
|
2021-01-12 16:42:58 +01:00
|
|
|
|
2021-03-16 12:10:07 +01:00
|
|
|
/**
|
2021-06-17 12:08:09 +02:00
|
|
|
* @var null|Date
|
2021-03-16 12:10:07 +01:00
|
|
|
*/
|
|
|
|
protected $postponedDate;
|
|
|
|
|
2021-06-17 12:08:09 +02:00
|
|
|
/**
|
|
|
|
* @var null|Date
|
|
|
|
*/
|
|
|
|
protected $originalDate;
|
|
|
|
|
2019-07-18 13:44:19 +02:00
|
|
|
/**
|
|
|
|
* @var \Wrm\Events\Domain\Model\Event
|
|
|
|
*/
|
|
|
|
protected $event = null;
|
|
|
|
|
2021-03-16 16:05:39 +01:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $canceledLink = '';
|
|
|
|
|
2020-10-01 08:34:13 +02:00
|
|
|
/**
|
|
|
|
* @var int
|
|
|
|
*/
|
2020-10-01 08:56:44 +02:00
|
|
|
protected $_languageUid;
|
2020-10-01 08:34:13 +02:00
|
|
|
|
2019-07-18 13:44:19 +02:00
|
|
|
/**
|
|
|
|
* @return \DateTime $start
|
|
|
|
*/
|
|
|
|
public function getStart()
|
|
|
|
{
|
|
|
|
return $this->start;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param \DateTime $start
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setStart(\DateTime $start)
|
|
|
|
{
|
|
|
|
$this->start = $start;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return \DateTime end
|
|
|
|
*/
|
|
|
|
public function getEnd()
|
|
|
|
{
|
|
|
|
return $this->end;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-10-11 15:12:07 +02:00
|
|
|
* @param \DateTime $end
|
2019-07-18 13:44:19 +02:00
|
|
|
* @return void
|
|
|
|
*/
|
2019-10-11 15:12:07 +02:00
|
|
|
public function setEnd(\DateTime $end)
|
2019-07-18 13:44:19 +02:00
|
|
|
{
|
|
|
|
$this->end = $end;
|
|
|
|
}
|
|
|
|
|
2021-03-11 17:39:15 +01:00
|
|
|
|
2021-01-12 16:42:58 +01:00
|
|
|
|
2019-07-18 13:44:19 +02:00
|
|
|
/**
|
|
|
|
* @return Event
|
|
|
|
*/
|
|
|
|
public function getEvent(): Event
|
|
|
|
{
|
|
|
|
return $this->event;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Event $event
|
|
|
|
*/
|
|
|
|
public function setEvent(Event $event): self
|
|
|
|
{
|
|
|
|
$this->event = $event;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2020-10-01 08:34:13 +02:00
|
|
|
/**
|
|
|
|
* @param int $languageUid
|
|
|
|
* @return void
|
|
|
|
*/
|
2021-01-07 08:50:43 +01:00
|
|
|
public function setLanguageUid($languageUid)
|
|
|
|
{
|
2020-10-01 08:56:44 +02:00
|
|
|
$this->_languageUid = $languageUid;
|
2020-10-01 08:34:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return int
|
|
|
|
*/
|
2021-01-07 08:50:43 +01:00
|
|
|
public function getLanguageUid()
|
|
|
|
{
|
2020-10-01 08:56:44 +02:00
|
|
|
return $this->_languageUid;
|
2020-10-01 08:34:13 +02:00
|
|
|
}
|
2021-03-11 17:39:15 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getCanceled(): string
|
|
|
|
{
|
|
|
|
return $this->canceled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $canceled
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function setCanceled(string $canceled)
|
|
|
|
{
|
|
|
|
$this->canceled = $canceled;
|
|
|
|
}
|
2021-03-16 12:10:07 +01:00
|
|
|
|
|
|
|
public function getPostponedDate(): ?Date
|
|
|
|
{
|
|
|
|
if ($this->getCanceled() === 'postponed') {
|
|
|
|
return $this->postponedDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2021-03-16 16:05:39 +01:00
|
|
|
|
2021-06-17 12:08:09 +02:00
|
|
|
public function getOriginalDate(): ?Date
|
|
|
|
{
|
|
|
|
return $this->originalDate;
|
|
|
|
}
|
|
|
|
|
2021-03-16 16:05:39 +01:00
|
|
|
public function getCanceledLink(): string
|
|
|
|
{
|
|
|
|
if ($this->getCanceled() === 'canceled') {
|
|
|
|
return $this->canceledLink;
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
2021-09-07 08:36:48 +02:00
|
|
|
|
2022-04-21 08:07:25 +02:00
|
|
|
public static function createFromDestinationDataDate(
|
|
|
|
array $date,
|
|
|
|
bool $canceled
|
|
|
|
): self {
|
|
|
|
return self::createFromDestinationData(
|
2022-07-07 14:10:49 +02:00
|
|
|
new \DateTimeImmutable($date['start'], new \DateTimeZone($date['tz'])),
|
|
|
|
new \DateTimeImmutable($date['end'], new \DateTimeZone($date['tz'])),
|
2022-04-21 08:07:25 +02:00
|
|
|
$canceled
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-07 08:36:48 +02:00
|
|
|
public static function createFromDestinationData(
|
2022-07-07 14:10:49 +02:00
|
|
|
\DateTimeImmutable $start,
|
|
|
|
\DateTimeImmutable $end,
|
2021-09-07 08:36:48 +02:00
|
|
|
bool $canceled
|
|
|
|
): self {
|
|
|
|
$date = new Date();
|
|
|
|
$date->setLanguageUid(-1);
|
|
|
|
|
2022-07-07 14:10:49 +02:00
|
|
|
$date->setStart(new \DateTime($start->format(\DateTime::W3C), $start->getTimezone()));
|
|
|
|
$date->setEnd(new \DateTime($end->format(\DateTime::W3C), $end->getTimezone()));
|
2021-09-07 08:36:48 +02:00
|
|
|
|
|
|
|
if ($canceled) {
|
|
|
|
$date->setCanceled('canceled');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $date;
|
|
|
|
}
|
2019-07-18 13:44:19 +02:00
|
|
|
}
|