<?php

declare(strict_types=1);

namespace App\Entity\Education;

use ApiPlatform\Metadata\ApiResource;
use App\Entity\Core\Tagg;
use App\Entity\Organization\Organization;
use App\Entity\Product\Intangible;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

/**
 * TODO: documenter.
 */
#[ApiResource(operations: [])]
#[ORM\Entity]
class EducationCurriculumPack
{
    #[ORM\Id]
    #[ORM\Column]
    #[ORM\GeneratedValue]
    private int $id;

    #[ORM\ManyToOne(targetEntity: Organization::class, cascade: [], inversedBy: 'educationCurriculumPacks')]
    #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
    public Organization $organization;

    /** @var Collection<int, Tagg> */
    #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'educationCurriculumPacks', cascade: ['persist'], orphanRemoval: false)]
    #[ORM\JoinTable(name: 'tag_educationCurriculumPack')]
    #[ORM\JoinColumn(name: 'educationcurriculumpack_id', onDelete: 'CASCADE')]
    #[ORM\InverseJoinColumn(name: 'tagg_id', onDelete: 'CASCADE')]
    public Collection $tags;

    /** @var Collection<int, EducationCurriculum> */
    #[ORM\ManyToMany(
        targetEntity: EducationCurriculum::class,
        inversedBy: 'requiredEducationCurriculumPacks',
        cascade: [],
        orphanRemoval: false,
    )]
    #[ORM\JoinTable(name: 'educationCurriculumPack_requiredEducationCurriculum')]
    public Collection $requiredEducationCurriculums;

    /** @var Collection<int, EducationCurriculum> */
    #[ORM\ManyToMany(
        targetEntity: EducationCurriculum::class,
        inversedBy: 'optionnalEducationCurriculumPacks',
        cascade: [],
        orphanRemoval: false,
    )]
    #[ORM\JoinTable(name: 'educationCurriculumPack_optionnalEducationCurriculum')]
    public Collection $optionnalEducationCurriculums;

    /** @var Collection<int, Intangible> */
    #[ORM\ManyToMany(targetEntity: Intangible::class, mappedBy: 'educationCurriculumPacks', cascade: [], orphanRemoval: false)]
    public Collection $intangibles;

    /** @var Collection<int, RequiredChoicesBlock> */
    #[ORM\OneToMany(
        targetEntity: RequiredChoicesBlock::class,
        mappedBy: 'educationCurriculumPacks',
        cascade: ['persist', 'remove'],
        orphanRemoval: true,
    )]
    protected Collection $requiredChoicesBlocks;

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

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

    public function setId(int $id): self
    {
        $this->id = $id;

        return $this;
    }

    public function getOrganization(): Organization
    {
        return $this->organization;
    }

    public function setOrganization(Organization $organization): self
    {
        $this->organization = $organization;

        return $this;
    }

    public function getTags(): Collection
    {
        return $this->tags;
    }

    public function addTag(Tagg $tag): self
    {
        if (!$this->tags->contains($tag)) {
            $this->tags[] = $tag;
            $tag->addEducationCurriculumPack($this);
        }

        return $this;
    }

    public function removeTag(Tagg $tag): self
    {
        if ($this->tags->removeElement($tag)) {
            $tag->removeEducationCurriculumPack($this);
        }

        return $this;
    }

    public function getRequiredEducationCurriculums(): Collection
    {
        return $this->requiredEducationCurriculums;
    }

    public function addRequiredEducationCurriculum(EducationCurriculum $requiredEducationCurriculum): self
    {
        if (!$this->requiredEducationCurriculums->contains($requiredEducationCurriculum)) {
            $this->requiredEducationCurriculums[] = $requiredEducationCurriculum;
            $requiredEducationCurriculum->addRequiredEducationCurriculumPack($this);
        }

        return $this;
    }

    public function removeRequiredEducationCurriculum(EducationCurriculum $requiredEducationCurriculum): self
    {
        if ($this->requiredEducationCurriculums->removeElement($requiredEducationCurriculum)) {
            $requiredEducationCurriculum->removeRequiredEducationCurriculumPack($this);
        }

        return $this;
    }

    public function getOptionnalEducationCurriculums(): Collection
    {
        return $this->optionnalEducationCurriculums;
    }

    public function addOptionnalEducationCurriculum(EducationCurriculum $optionnalEducationCurriculum): self
    {
        if (!$this->optionnalEducationCurriculums->contains($optionnalEducationCurriculum)) {
            $this->optionnalEducationCurriculums[] = $optionnalEducationCurriculum;
            $optionnalEducationCurriculum->addOptionnalEducationCurriculumPack($this);
        }

        return $this;
    }

    public function removeOptionnalEducationCurriculum(EducationCurriculum $optionnalEducationCurriculum): self
    {
        if ($this->optionnalEducationCurriculums->removeElement($optionnalEducationCurriculum)) {
            $optionnalEducationCurriculum->removeOptionnalEducationCurriculumPack($this);
        }

        return $this;
    }

    public function getIntangibles(): Collection
    {
        return $this->intangibles;
    }

    public function addIntangible(Intangible $intangible): self
    {
        if (!$this->intangibles->contains($intangible)) {
            $this->intangibles[] = $intangible;
            $intangible->addEducationCurriculumPack($this);
        }

        return $this;
    }

    public function removeIntangible(Intangible $intangible): self
    {
        if ($this->intangibles->removeElement($intangible)) {
            $intangible->removeEducationCurriculumPack($this);
        }

        return $this;
    }

    public function getRequiredChoicesBlocks(): Collection
    {
        return $this->requiredChoicesBlocks;
    }

    public function addRequiredChoicesBlock(RequiredChoicesBlock $requiredChoicesBlock): self
    {
        if (!$this->requiredChoicesBlocks->contains($requiredChoicesBlock)) {
            $this->requiredChoicesBlocks[] = $requiredChoicesBlock;
            $requiredChoicesBlock->setEducationCurriculumPack($this);
        }

        return $this;
    }

    public function removeRequiredChoicesBlock(RequiredChoicesBlock $requiredChoicesBlock): self
    {
        $this->requiredChoicesBlocks->removeElement($requiredChoicesBlock);

        return $this;
    }
}
