<?php declare(strict_types=1);

namespace App\Engine\UpcomingEvent;

use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity]
class UpcomingEvent
{

    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column(type: 'integer')]
    private ?int $id = null;
    #[ORM\Column(type: 'string', enumType: UpcomingEventType::class)]
    private UpcomingEventType $type = UpcomingEventType::Event;
    #[ORM\Column(type: 'string', length: 180, nullable: true)]
    private ?string $urlPart = null;
    #[ORM\Column(type: 'string')]
    private string $title = "";
    #[ORM\Column(type: 'text')]
    private string $summary = "";
    #[ORM\Column(type: 'text')]
    private string $rowSummary = "";
    #[ORM\Column(type: 'text')]
    private string $text = "";
    #[ORM\Column(type: 'string')]
    private string $coverImage = ""; // Použít i pro metaImage
    #[ORM\Column(type: 'string')]
    private ?string $mainImage = "";
    #[ORM\Column(type: 'boolean')]
    private bool $showOnHp = false;
    #[ORM\Column(type: 'boolean')]
    private bool $enabled = true;
    #[ORM\Column(type: 'boolean')]
    private bool $withDetail = true;

    #[ORM\Column(type: 'datetime', nullable: true)]
    private ?\DateTime $publishFrom = null;
    #[ORM\Column(type: 'datetime', nullable: true)]
    private ?\DateTime $publishTo = null;
    #[ORM\Column(type: 'datetime', nullable: true)]
    private ?\DateTime $archiveTo = null;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function setId(?int $id): UpcomingEvent
    {
        $this->id = $id;
        return $this;
    }

    public function getType(): UpcomingEventType
    {
        return $this->type;
    }

    public function setType(UpcomingEventType $type): UpcomingEvent
    {
        $this->type = $type;
        return $this;
    }

    public function getUrlPart(): ?string
    {
        return $this->urlPart;
    }

    public function setUrlPart(?string $urlPart): UpcomingEvent
    {
        if ($urlPart) {
            $urlPart = \App\Engine\Utills\StringHelpers::sanitizeUrlAsAbsoulutePath($urlPart);
        }

        $this->urlPart = $urlPart;
        return $this;
    }

    public function getUrl(): string
    {
        return \App\Engine\Localization\TranslatorStaticProxy::getInstance()->trans("fe.upcoming-event.detail-url") . $this->getUrlPart();
    }

    public function getTitle(): string
    {
        return $this->title;
    }

    public function setTitle(string $title): UpcomingEvent
    {
        $this->title = $title;
        return $this;
    }

    public function getSummary(): string
    {
        return $this->summary;
    }

    public function setSummary(string $summary): UpcomingEvent
    {
        $this->summary = $summary;
        return $this;
    }

    public function getText(): string
    {
        return $this->text;
    }

    public function setText(string $text): UpcomingEvent
    {
        $this->text = $text;
        return $this;
    }

    public function getCoverImage(): string
    {
        return $this->coverImage;
    }

    public function setCoverImage(string $coverImage): UpcomingEvent
    {
        $this->coverImage = $coverImage;
        return $this;
    }

    public function getMainImage(): ?string
    {
        return $this->mainImage;
    }

    public function setMainImage(string $mainImage): UpcomingEvent
    {
        $this->mainImage = $mainImage;
        return $this;
    }

    public function getMainOrFallbackImage(): string
    {
        return $this->mainImage ?: "/assets/images/frontend/subpage/header/deafult-upcoming-event.png";
    }

    public function isShowOnHp(): bool
    {
        return $this->showOnHp;
    }

    public function setShowOnHp(bool $showOnHp): UpcomingEvent
    {
        $this->showOnHp = $showOnHp;
        return $this;
    }

    public function isEnabled(): bool
    {
        return $this->enabled;
    }

    public function setEnabled(bool $enabled): UpcomingEvent
    {
        $this->enabled = $enabled;
        return $this;
    }

    public function getPublishFrom(): ?\DateTime
    {
        return $this->publishFrom;
    }

    public function setPublishFrom(?\DateTime $publishFrom): UpcomingEvent
    {
        $this->publishFrom = $publishFrom;
        return $this;
    }

    public function getPublishTo(): ?\DateTime
    {
        return $this->publishTo;
    }

    public function setPublishTo(?\DateTime $publishTo): UpcomingEvent
    {
        $this->publishTo = $publishTo;
        return $this;
    }

    public function getArchiveTo(): ?\DateTime
    {
        return $this->archiveTo;
    }

    public function setArchiveTo(?\DateTime $archiveTo): UpcomingEvent
    {
        $this->archiveTo = $archiveTo;
        return $this;
    }

    public function getRowSummary(): string
    {
        return $this->rowSummary;
    }

    public function setRowSummary(string $rowSummary): void
    {
        $this->rowSummary = $rowSummary;
    }

    public function isWithDetail(): bool
    {
        return $this->withDetail;
    }

    public function setWithDetail(bool $withDetail): void
    {
        $this->withDetail = $withDetail;
    }

}