<?php

namespace App\Entity;

use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\TPcMatrixesMilestonesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;

use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Serializer\Filter\PropertyFilter;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @ApiResource(
 *    normalizationContext={"groups"={"t_pc_matrixes_milestones:read"}, "enable_max_depth"="true", "swagger_definition_name"="Read"},
 *    denormalizationContext={"groups"={"t_pc_matrixes_milestones:write"}, "swagger_definition_name"="Write"}
 * )
 * @ApiFilter(SearchFilter::class, properties={ "id": "exact", "pc": "exact", "pcMatrix": "exact" })
 * @ApiFilter(PropertyFilter::class)
 * @ORM\Entity(repositoryClass=TPcMatrixesMilestonesRepository::class)
 */

class TPcMatrixesMilestones
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({ "t_pc_matrixes_milestones:read", "t_pc_matrixes_milestones:write", "t_pc_matrixes_milestones_cascades:read" })
     */
    private $id;

    /**
     * @ORM\ManyToOne(targetEntity=TMainTargetsPlannings::class, inversedBy="tPcMatrixesMilestones")
     * @Groups({ "t_pc_matrixes_milestones:read", "t_pc_matrixes_milestones:write" })
     */
    private $pc;

    /**
     * @ORM\ManyToOne(targetEntity=TPcMatrixes::class, inversedBy="tPcMatrixesMilestones")
     * @Groups({ "t_pc_matrixes_milestones:read", "t_pc_matrixes_milestones:write", "t_pc_matrixes_milestones_cascades:read" })
     */
    private $pcMatrix;

    /**
     * @ORM\Column(type="text", nullable=true)
     * @Groups({ "t_pc_matrixes_milestones:read", "t_pc_matrixes_milestones:write" })
     */
    private $activityName;

    /**
     * @ORM\Column(type="decimal", precision=60, scale=2, nullable=true)
     * @Groups({ "t_pc_matrixes_milestones:read", "t_pc_matrixes_milestones:write" })
     */
    private $weight;

    /**
     * @ORM\Column(type="decimal", precision=60, scale=2, nullable=true)
     * @Groups({ "t_pc_matrixes_milestones:read", "t_pc_matrixes_milestones:write" })
     */
    private $target;

    /**
     * @ORM\OneToMany(targetEntity=TPcMatrixesMilestonesCascades::class, mappedBy="majorCascade")
     * @Groups({ "t_pc_matrixes_milestones:read", "t_pc_matrixes_milestones:write" })
     */
    private $tPcMatrixesMilestonesCascades;

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

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

    public function getPc(): ?TMainTargetsPlannings
    {
        return $this->pc;
    }

    public function setPc(?TMainTargetsPlannings $pc): self
    {
        $this->pc = $pc;

        return $this;
    }

    public function getPcMatrix(): ?TPcMatrixes
    {
        return $this->pcMatrix;
    }

    public function setPcMatrix(?TPcMatrixes $pcMatrix): self
    {
        $this->pcMatrix = $pcMatrix;

        return $this;
    }

    public function getActivityName(): ?string
    {
        return $this->activityName;
    }

    public function setActivityName(?string $activityName): self
    {
        $this->activityName = $activityName;

        return $this;
    }

    public function getWeight(): ?string
    {
        return $this->weight;
    }

    public function setWeight(?string $weight): self
    {
        $this->weight = $weight;

        return $this;
    }

    public function getTarget(): ?string
    {
        return $this->target;
    }

    public function setTarget(?string $target): self
    {
        $this->target = $target;

        return $this;
    }

    /**
     * @return Collection|TPcMatrixesMilestonesCascades[]
     */
    public function getTPcMatrixesMilestonesCascades(): Collection
    {
        return $this->tPcMatrixesMilestonesCascades;
    }

    public function addTPcMatrixesMilestonesCascade(TPcMatrixesMilestonesCascades $tPcMatrixesMilestonesCascade): self
    {
        if (!$this->tPcMatrixesMilestonesCascades->contains($tPcMatrixesMilestonesCascade)) {
            $this->tPcMatrixesMilestonesCascades[] = $tPcMatrixesMilestonesCascade;
            $tPcMatrixesMilestonesCascade->setMajorCascade($this);
        }

        return $this;
    }

    public function removeTPcMatrixesMilestonesCascade(TPcMatrixesMilestonesCascades $tPcMatrixesMilestonesCascade): self
    {
        if ($this->tPcMatrixesMilestonesCascades->removeElement($tPcMatrixesMilestonesCascade)) {
            // set the owning side to null (unless already changed)
            if ($tPcMatrixesMilestonesCascade->getMajorCascade() === $this) {
                $tPcMatrixesMilestonesCascade->setMajorCascade(null);
            }
        }

        return $this;
    }
}
