<?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\ProfessionDetailRepository;
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_detail"}},
* normalizationContext={"groups"={"read_profession_detail"}, "enable_max_depth"=true},
* cacheHeaders={"max_age"=86400, "shared_max_age"=86400},
* collectionOperations={
* "get",
* "post",
* "profession_detail_all"={
* "method"="GET",
* "path"="/profession_details/all"
* }
* },
* itemOperations={"get", "put"}
* )
* @ApiFilter(SearchFilter::class, properties={"professionType.id":"exact", "label": "partial", "code": "partial"})
* @ORM\Entity(repositoryClass=ProfessionDetailRepository::class)
*/
class ProfessionDetail
{
/**
* @Groups({"write_profession_detail", "read_profession_detail", "read_organization", "read_activity_three"})
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @Groups({"write_profession_detail", "read_profession_detail", "admin_orga_list", "read_organization", "read_activity_three"})
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $label = null;
/**
* @Groups({"write_profession_detail", "read_profession_detail", "admin_orga_list", "read_organization", "read_activity_three"})
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $code = null;
/**
* @Groups({"write_profession_detail", "read_profession_detail", "admin_orga_list", "read_organization"})
* @ORM\ManyToOne(targetEntity=ProfessionType::class, inversedBy="professionDetails")
*/
private ?ProfessionType $professionType = null;
/**
* @ORM\OneToMany(targetEntity=Organization::class, mappedBy="activityCategory")
*/
private ?Collection $organizations;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $finalCode = null;
public function __construct()
{
$this->organizations = 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 getProfessionType(): ?ProfessionType
{
return $this->professionType;
}
public function setProfessionType(?ProfessionType $professionType): self
{
$this->professionType = $professionType;
return $this;
}
/**
* @return Collection<int, Organization>
*/
public function getOrganizations(): Collection
{
return $this->organizations;
}
public function addOrganization(Organization $organization): self
{
if (!$this->organizations->contains($organization)) {
$this->organizations[] = $organization;
$organization->setActivityCategory($this);
}
return $this;
}
public function removeOrganization(Organization $organization): self
{
// set the owning side to null (unless already changed)
if ($this->organizations->removeElement($organization) && $organization->getActivityCategory() === $this) {
$organization->setActivityCategory(null);
}
return $this;
}
public function getFinalCode(): ?string
{
return $this->finalCode;
}
public function setFinalCode(?string $finalCode): self
{
$this->finalCode = $finalCode;
return $this;
}
}