<?php

namespace App\Entity\Territory;

use App\Entity\CollectifData\CollectifData;
use Lc\PietroBundle\Repository\Territory\TerritoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\PietroBundle\Model\Territory\Territory as PietroTerritory;

/**
 * @ORM\Entity(repositoryClass=TerritoryRepository::class)
 */
class Territory extends PietroTerritory
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\OneToMany(targetEntity=CollectifData::class, mappedBy="territory")
     */
    private $collectifData;

    public function __construct()
    {
        parent::__construct();
        $this->collectifData = new ArrayCollection();
    }

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

    /**
     * @return Collection|CollectifData[]
     */
    public function getCollectifData(): Collection
    {
        return $this->collectifData;
    }

    public function addCollectifData(CollectifData $collectifData): self
    {
        if (!$this->collectifData->contains($collectifData)) {
            $this->collectifData[] = $collectifData;
            $collectifData->setTerritory($this);
        }

        return $this;
    }

    public function removeCollectifData(CollectifData $collectifData): self
    {
        if ($this->collectifData->removeElement($collectifData)) {
            // set the owning side to null (unless already changed)
            if ($collectifData->getTerritory() === $this) {
                $collectifData->setTerritory(null);
            }
        }

        return $this;
    }

}
