src/Evo/Infrastructure/MappingORM/ProfessionType.php line 32

Open in your IDE?
  1. <?php
  2. namespace Evo\Infrastructure\MappingORM;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  6. use App\Repository\ProfessionTypeRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. /**
  12.  * @ApiResource(
  13.  *     denormalizationContext={"groups"={"write_profession_type"}},
  14.  *     normalizationContext={"groups"={"read_profession_type", "read_activity_three"}, "enable_max_depth"=true},
  15.  *     cacheHeaders={"max_age"=86400, "shared_max_age"=86400},
  16.  *     collectionOperations={
  17.  *         "get",
  18.  *         "post",
  19.  *         "profession_type_all"={
  20.  *             "method"="GET",
  21.  *             "path"="/profession_types/all"
  22.  *         }
  23.  *     },
  24.  *     itemOperations={"get", "put"}
  25.  * )
  26.  * @ApiFilter(SearchFilter::class, properties={"activitySubdomain.id":"exact", "label": "partial", "code": "partial"})
  27.  * @ORM\Entity(repositoryClass=ProfessionTypeRepository::class)
  28.  */
  29. class ProfessionType
  30. {
  31.     /**
  32.      * @Groups({"write_profession_type", "read_profession_type", "read_activity_two", "read_activity_three"})
  33.      * @ORM\Id
  34.      * @ORM\GeneratedValue
  35.      * @ORM\Column(type="integer")
  36.      */
  37.     private ?int $id null;
  38.     /**
  39.      * @Groups({"write_profession_type", "read_profession_type", "read_activity_two", "read_activity_three"})
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      */
  42.     private ?string $label null;
  43.     /**
  44.      * @Groups({"write_profession_type", "read_profession_type", "read_activity_two", "read_activity_three"})
  45.      * @ORM\Column(type="string", length=255, nullable=true)
  46.      */
  47.     private ?string $code null;
  48.     /**
  49.      * @Groups({"write_profession_type", "read_profession_type"})
  50.      * @ORM\ManyToOne(targetEntity=ActivitySubdomain::class, inversedBy="professionTypes")
  51.      */
  52.     private ?ActivitySubdomain $activitySubdomain null;
  53.     /**
  54.      * @Groups({"write_profession_type", "read_profession_type", "read_activity_three"})
  55.      * @ORM\OneToMany(targetEntity=ProfessionDetail::class, mappedBy="professionType")
  56.      */
  57.     private ?Collection $professionDetails;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private ?string $finalCode null;
  62.     public function __construct()
  63.     {
  64.         $this->professionDetails = new ArrayCollection();
  65.     }
  66.     public function getId(): ?int
  67.     {
  68.         return $this->id;
  69.     }
  70.     public function getLabel(): ?string
  71.     {
  72.         return $this->label;
  73.     }
  74.     public function setLabel(?string $label): self
  75.     {
  76.         $this->label $label;
  77.         return $this;
  78.     }
  79.     public function getCode(): ?string
  80.     {
  81.         return $this->code;
  82.     }
  83.     public function setCode(?string $code): self
  84.     {
  85.         $this->code $code;
  86.         return $this;
  87.     }
  88.     public function getActivitySubdomain(): ?ActivitySubdomain
  89.     {
  90.         return $this->activitySubdomain;
  91.     }
  92.     public function setActivitySubdomain(?ActivitySubdomain $activitySubdomain): self
  93.     {
  94.         $this->activitySubdomain $activitySubdomain;
  95.         return $this;
  96.     }
  97.     /**
  98.      * @return Collection<int, ProfessionDetail>
  99.      */
  100.     public function getProfessionDetails(): Collection
  101.     {
  102.         return $this->professionDetails;
  103.     }
  104.     public function addProfessionDetail(ProfessionDetail $professionDetail): self
  105.     {
  106.         if (!$this->professionDetails->contains($professionDetail)) {
  107.             $this->professionDetails[] = $professionDetail;
  108.             $professionDetail->setProfessionType($this);
  109.         }
  110.         return $this;
  111.     }
  112.     public function removeProfessionDetail(ProfessionDetail $professionDetail): self
  113.     {
  114.         // set the owning side to null (unless already changed)
  115.         if ($this->professionDetails->removeElement($professionDetail) && $professionDetail->getProfessionType() === $this) {
  116.             $professionDetail->setProfessionType(null);
  117.         }
  118.         return $this;
  119.     }
  120.     public function getFinalCode(): ?string
  121.     {
  122.         return $this->finalCode;
  123.     }
  124.     public function setFinalCode(?string $finalCode): self
  125.     {
  126.         $this->finalCode $finalCode;
  127.         return $this;
  128.     }
  129. }