<?php
namespace Evo\Infrastructure\MappingORM;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use App\Repository\ProfessionTypeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* denormalizationContext={"groups"={"write_profession_type"}},
* normalizationContext={"groups"={"read_profession_type", "read_activity_three"}, "enable_max_depth"=true},
* cacheHeaders={"max_age"=86400, "shared_max_age"=86400},
* collectionOperations={
* "get",
* "post",
* "profession_type_all"={
* "method"="GET",
* "path"="/profession_types/all"
* }
* },
* itemOperations={"get", "put"}
* )
* @ApiFilter(SearchFilter::class, properties={"activitySubdomain.id":"exact", "label": "partial", "code": "partial"})
* @ORM\Entity(repositoryClass=ProfessionTypeRepository::class)
*/
class ProfessionType
{
/**
* @Groups({"write_profession_type", "read_profession_type", "read_activity_two", "read_activity_three"})
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @Groups({"write_profession_type", "read_profession_type", "read_activity_two", "read_activity_three"})
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $label = null;
/**
* @Groups({"write_profession_type", "read_profession_type", "read_activity_two", "read_activity_three"})
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $code = null;
/**
* @Groups({"write_profession_type", "read_profession_type"})
* @ORM\ManyToOne(targetEntity=ActivitySubdomain::class, inversedBy="professionTypes")
*/
private ?ActivitySubdomain $activitySubdomain = null;
/**
* @Groups({"write_profession_type", "read_profession_type", "read_activity_three"})
* @ORM\OneToMany(targetEntity=ProfessionDetail::class, mappedBy="professionType")
*/
private ?Collection $professionDetails;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $finalCode = null;
public function __construct()
{
$this->professionDetails = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(?string $label): self
{
$this->label = $label;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(?string $code): self
{
$this->code = $code;
return $this;
}
public function getActivitySubdomain(): ?ActivitySubdomain
{
return $this->activitySubdomain;
}
public function setActivitySubdomain(?ActivitySubdomain $activitySubdomain): self
{
$this->activitySubdomain = $activitySubdomain;
return $this;
}
/**
* @return Collection<int, ProfessionDetail>
*/
public function getProfessionDetails(): Collection
{
return $this->professionDetails;
}
public function addProfessionDetail(ProfessionDetail $professionDetail): self
{
if (!$this->professionDetails->contains($professionDetail)) {
$this->professionDetails[] = $professionDetail;
$professionDetail->setProfessionType($this);
}
return $this;
}
public function removeProfessionDetail(ProfessionDetail $professionDetail): self
{
// set the owning side to null (unless already changed)
if ($this->professionDetails->removeElement($professionDetail) && $professionDetail->getProfessionType() === $this) {
$professionDetail->setProfessionType(null);
}
return $this;
}
public function getFinalCode(): ?string
{
return $this->finalCode;
}
public function setFinalCode(?string $finalCode): self
{
$this->finalCode = $finalCode;
return $this;
}
}