<?php

namespace App\Entity\Content;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity()
 * @ORM\Table(name="content_workflow")
 */
class Workflow
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

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

    /**
     * @ORM\OneToMany(targetEntity="App\Entity\Content\Type", mappedBy="workflow")
     */
    private $contentTypes;

    /**
     * @ORM\OneToMany(targetEntity="App\Entity\Content\Status", mappedBy="workflow")
     */
    private $contentStatuses;

    public function __construct()
    {
        $this->contentTypes = new ArrayCollection();
        $this->contentStatuses = 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;
    }

    /**
     * @return Collection
     */
    public function getContentTypes(): Collection
    {
        return $this->contentTypes;
    }

    public function addContentType(Type $contentType): self
    {
        if (!$this->contentTypes->contains($contentType)) {
            $this->contentTypes[] = $contentType;
            $contentType->setWorkflow($this);
        }

        return $this;
    }

    public function removeContentType(Type $contentType): self
    {
        if ($this->contentTypes->contains($contentType)) {
            $this->contentTypes->removeElement($contentType);
            // set the owning side to null (unless already changed)
            if ($contentType->getWorkflow() === $this) {
                $contentType->setWorkflow(null);
            }
        }

        return $this;
    }

    /**
     * @return Collection
     */
    public function getContentStatuses(): Collection
    {
        return $this->contentStatuses;
    }

    public function addContentStatus(Status $contentStatus): self
    {
        if (!$this->contentStatuses->contains($contentStatus)) {
            $this->contentStatuses[] = $contentStatus;
            $contentStatus->setWorkflow($this);
        }

        return $this;
    }

    public function removeContentStatus(Status $contentStatus): self
    {
        if ($this->contentStatuses->contains($contentStatus)) {
            $this->contentStatuses->removeElement($contentStatus);
            // set the owning side to null (unless already changed)
            if ($contentStatus->getWorkflow() === $this) {
                $contentStatus->setWorkflow(null);
            }
        }

        return $this;
    }
}
