<?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\ActivitySubdomainRepository;
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_activity_subdomain"}},
* normalizationContext={"groups"={"read_activity_subdomain", "read_activity_two"}, "enable_max_depth"=true},
* collectionOperations={
* "get",
* "post",
* "activity_subdomain_all"={
* "method"="GET",
* "path"="/activity_subdomains/all"
* }
* },
* itemOperations={"get", "put"}
* )
* @ApiFilter(SearchFilter::class, properties={"activityDomain.id":"exact", "label": "partial", "code": "partial"})
* @ORM\Entity(repositoryClass=ActivitySubdomainRepository::class)
*/
class ActivitySubdomain
{
/**
* @Groups({"write_activity_subdomain", "read_activity_subdomain", "read_activity_one", "read_activity_two"})
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id = null;
/**
* @Groups({"write_activity_subdomain", "read_activity_subdomain", "read_activity_one", "read_activity_two"})
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $label = null;
/**
* @Groups({"write_activity_subdomain", "read_activity_subdomain", "read_activity_one", "read_activity_two"})
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $code = null;
/**
* @Groups({"write_activity_subdomain", "read_activity_subdomain"})
* @ORM\ManyToOne(targetEntity=ActivityDomain::class, inversedBy="actFieldDetails")
*/
private ?ActivityDomain $activityDomain = null;
/**
* @Groups({"write_activity_subdomain", "read_activity_subdomain", "read_activity_two"})
* @ORM\OneToMany(targetEntity=ProfessionType::class, mappedBy="activitySubdomain")
*/
private ?Collection $professionTypes;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $finalCode = null;
public function __construct()
{
$this->professionTypes = 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 getActivityDomain(): ?ActivityDomain
{
return $this->activityDomain;
}
public function setActivityDomain(?ActivityDomain $activityDomain): self
{
$this->activityDomain = $activityDomain;
return $this;
}
/**
* @return Collection<int, ProfessionType>
*/
public function getProfessionTypes(): Collection
{
return $this->professionTypes;
}
public function addProfessionType(ProfessionType $professionType): self
{
if (!$this->professionTypes->contains($professionType)) {
$this->professionTypes[] = $professionType;
$professionType->setActivitySubdomain($this);
}
return $this;
}
public function removeProfessionType(ProfessionType $professionType): self
{
// set the owning side to null (unless already changed)
if ($this->professionTypes->removeElement($professionType) && $professionType->getActivitySubdomain() === $this) {
$professionType->setActivitySubdomain(null);
}
return $this;
}
public function getFinalCode(): ?string
{
return $this->finalCode;
}
public function setFinalCode(?string $finalCode): self
{
$this->finalCode = $finalCode;
return $this;
}
}