src/Evo/Infrastructure/MappingORM/ProfessionDetail.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\ProfessionDetailRepository;
  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_detail"}},
  14.  *     normalizationContext={"groups"={"read_profession_detail"}, "enable_max_depth"=true},
  15.  *     cacheHeaders={"max_age"=86400, "shared_max_age"=86400},
  16.  *     collectionOperations={
  17.  *         "get",
  18.  *         "post",
  19.  *         "profession_detail_all"={
  20.  *             "method"="GET",
  21.  *             "path"="/profession_details/all"
  22.  *         }
  23.  *     },
  24.  *     itemOperations={"get", "put"}
  25.  * )
  26.  * @ApiFilter(SearchFilter::class, properties={"professionType.id":"exact", "label": "partial", "code": "partial"})
  27.  * @ORM\Entity(repositoryClass=ProfessionDetailRepository::class)
  28.  */
  29. class ProfessionDetail
  30. {
  31.     /**
  32.      * @Groups({"write_profession_detail", "read_profession_detail", "read_organization", "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_detail", "read_profession_detail", "admin_orga_list", "read_organization", "read_activity_three"})
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      */
  42.     private ?string $label null;
  43.     /**
  44.      * @Groups({"write_profession_detail", "read_profession_detail", "admin_orga_list", "read_organization", "read_activity_three"})
  45.      * @ORM\Column(type="string", length=255, nullable=true)
  46.      */
  47.     private ?string $code null;
  48.     /**
  49.      * @Groups({"write_profession_detail", "read_profession_detail", "admin_orga_list", "read_organization"})
  50.      * @ORM\ManyToOne(targetEntity=ProfessionType::class, inversedBy="professionDetails")
  51.      */
  52.     private ?ProfessionType $professionType null;
  53.     /**
  54.      * @ORM\OneToMany(targetEntity=Organization::class, mappedBy="activityCategory")
  55.      */
  56.     private ?Collection $organizations;
  57.     /**
  58.      * @ORM\Column(type="string", length=255, nullable=true)
  59.      */
  60.     private ?string $finalCode null;
  61.     public function __construct()
  62.     {
  63.         $this->organizations = new ArrayCollection();
  64.     }
  65.     public function getId(): ?int
  66.     {
  67.         return $this->id;
  68.     }
  69.     public function getLabel(): ?string
  70.     {
  71.         return $this->label;
  72.     }
  73.     public function setLabel(?string $label): self
  74.     {
  75.         $this->label $label;
  76.         return $this;
  77.     }
  78.     public function getCode(): ?string
  79.     {
  80.         return $this->code;
  81.     }
  82.     public function setCode(?string $code): self
  83.     {
  84.         $this->code $code;
  85.         return $this;
  86.     }
  87.     public function getProfessionType(): ?ProfessionType
  88.     {
  89.         return $this->professionType;
  90.     }
  91.     public function setProfessionType(?ProfessionType $professionType): self
  92.     {
  93.         $this->professionType $professionType;
  94.         return $this;
  95.     }
  96.     /**
  97.      * @return Collection<int, Organization>
  98.      */
  99.     public function getOrganizations(): Collection
  100.     {
  101.         return $this->organizations;
  102.     }
  103.     public function addOrganization(Organization $organization): self
  104.     {
  105.         if (!$this->organizations->contains($organization)) {
  106.             $this->organizations[] = $organization;
  107.             $organization->setActivityCategory($this);
  108.         }
  109.         return $this;
  110.     }
  111.     public function removeOrganization(Organization $organization): self
  112.     {
  113.         // set the owning side to null (unless already changed)
  114.         if ($this->organizations->removeElement($organization) && $organization->getActivityCategory() === $this) {
  115.             $organization->setActivityCategory(null);
  116.         }
  117.         return $this;
  118.     }
  119.     public function getFinalCode(): ?string
  120.     {
  121.         return $this->finalCode;
  122.     }
  123.     public function setFinalCode(?string $finalCode): self
  124.     {
  125.         $this->finalCode $finalCode;
  126.         return $this;
  127.     }
  128. }