<?php

namespace App\Entity\Content;

use App\Entity\BroadcastableInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity()
 * @ORM\Table(name="content_status")
 */
class Status implements BroadcastableInterface
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=255)
     * @Assert\NotBlank()
     */
    private $title;

    /**
     * @ORM\Column(type="integer", nullable=true)
     */
    private $orderLvl;

    /**
     * @ORM\Column(type="text", nullable=true)
     */
    private $options;

    /**
     * @ORM\ManyToOne(targetEntity="App\Entity\Content\Workflow", inversedBy="contentStatuses")
     * @ORM\JoinColumn(nullable=false)
     * @Assert\NotBlank()
     */
    private $workflow;

    /**
     * @ORM\Column(type="boolean", options={"default": false})
     */
    private $contentLock;

    /**
     * @ORM\Column(type="boolean", options={"default": false})
     */
    private $enableCopyscape;

    public function __construct()
    {
        $this->contents = new ArrayCollection();
    }

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

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

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

        return $this;
    }

    public function getOrderLvl(): ?int
    {
        return $this->orderLvl;
    }

    public function setOrderLvl(?int $orderLvl): self
    {
        $this->orderLvl = $orderLvl;

        return $this;
    }

    public function getOptions()
    {
        return json_decode($this->options, true);
    }

    public function setOptions(?string $options): self
    {
        $this->options = $options;

        return $this;
    }

    public function getWorkflow(): ?Workflow
    {
        return $this->workflow;
    }

    public function setWorkflow(?Workflow $workflow): self
    {
        $this->workflow = $workflow;

        return $this;
    }

//    /**
//     * @return Collection|Content[]
//     */
//    public function getContents(): Collection
//    {
//        return $this->contents;
//    }
//
//    public function addContent(Content $content): self
//    {
//        if (!$this->contents->contains($content)) {
//            $this->contents[] = $content;
//            $content->setStatus($this);
//        }
//
//        return $this;
//    }
//
//    public function removeContent(Content $content): self
//    {
//        if ($this->contents->contains($content)) {
//            $this->contents->removeElement($content);
//            // set the owning side to null (unless already changed)
//            if ($content->getStatus() === $this) {
//                $content->setStatus(null);
//            }
//        }
//
//        return $this;
//    }
    public function getDataType(): string
    {
        return 'contentstatus';
    }

    public function getContentLock(): ?bool
    {
        return $this->contentLock;
    }

    public function setContentLock(?bool $contentLock): self
    {
        $this->contentLock = $contentLock;

        return $this;
    }

    public function getEnableCopyscape(): ?bool
    {
        return $this->enableCopyscape;
    }

    public function setEnableCopyscape(?bool $enableCopyscape): self
    {
        $this->enableCopyscape = $enableCopyscape;

        return $this;
    }
}
