<?php declare(strict_types=1);

namespace App\Engine\Page;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator as V;

#[ORM\Entity]
#[V\Constraints\UniqueEntity(fields: ["url"], message: "admin.navigation.validator.duplicate-url")]
class Page
{

    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column(type: 'integer')]
    private ?int $id = null;
    #[ORM\Column(type: 'string', nullable: true)]
    private ?string $internalIdentifier = null;
    #[ORM\Column(type: 'string', length: 180, unique: true)]
    private string $url = "";
    #[ORM\Column(type: 'string')]
    private string $title = "";
    #[ORM\Column(type: 'text')]
    private string $text = "";
    #[ORM\Column(type: 'boolean')]
    private bool $enabled = true;
    #[ORM\Column(type: 'boolean')]
    private bool $metaShouldIndex = true;
    #[ORM\Column(type: 'string')]
    private string $metaTitle = "";
    #[ORM\Column(type: 'text', length: 65535)]
    private string $metaDescription = "";

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

    public function getInternalIdentifier(): ?string
    {
        return $this->internalIdentifier;
    }

    public function getUrl(): string
    {
        return $this->url;
    }

    public function setUrl(?string $url): self
    {
        if ($url) {
            $url = \App\Engine\Utills\StringHelpers::sanitizeUrlAsAbsoulutePath($url);
        }

        $this->url = $url ?? "";
        return $this;
    }

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

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

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

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

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

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

    public function getMetaShouldIndex(): bool
    {
        return $this->metaShouldIndex;
    }

    public function setMetaShouldIndex(bool $metaShouldIndex): self
    {
        $this->metaShouldIndex = $metaShouldIndex;
        return $this;
    }

    public function getMetaTitle(): string
    {
        return $this->metaTitle;
    }

    public function setMetaTitle(?string $metaTitle): self
    {
        $this->metaTitle = $metaTitle ?? "";
        return $this;
    }

    public function getMetaDescription(): string
    {
        return $this->metaDescription;
    }

    public function setMetaDescription(?string $metaDescription): self
    {
        $this->metaDescription = $metaDescription ?? "";
        return $this;
    }

}