| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Organization;
- use ApiPlatform\Core\Annotation\ApiResource;
- use App\Repository\Organization\TypeOfPracticeRepository;
- use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use JetBrains\PhpStorm\Pure;
- use Symfony\Component\Serializer\Annotation\Groups;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * Type des pratique d'une organisation
- */
- #[Auditable]
- #[ApiResource(
- collectionOperations: [
- 'get' => [
- 'normalization_context' => [
- 'groups' => ['read']
- ]
- ]
- ],
- itemOperations: ['get'],
- attributes:[
- 'pagination_enabled' => false
- ]
- )]
- #[ORM\Entity(repositoryClass: TypeOfPracticeRepository::class)]
- class TypeOfPractice
- {
- #[ORM\Id]
- #[ORM\Column]
- #[ORM\GeneratedValue]
- #[Groups(["read"])]
- private ?int $id = null;
- #[ORM\Column(length: 255, nullable: true)]
- #[Assert\Choice(callback: ['\App\Enum\Cotisation\TypeOfPracticeEnum', 'toArray'], message: 'invalid-name')]
- #[Groups(["read"])]
- private ?string $name = null;
- #[ORM\Column(length: 255, nullable: true)]
- #[Assert\Choice(callback: ['\App\Enum\Cotisation\CategoryTypeOfPracticeEnum', 'toArray'], message: 'invalid-category')]
- #[Groups(["read"])]
- private ?string $category = null;
- #[ORM\ManyToMany(targetEntity: Organization::class, inversedBy: 'typeOfPractices')]
- #[ORM\JoinTable(name: 'organization_type_of_practices')]
- #[ORM\JoinColumn(name: 'typeofpractice_id', referencedColumnName: 'id')]
- #[ORM\InverseJoinColumn(name: 'organization_id', referencedColumnName: 'id')]
- private Collection $organizations;
- #[Pure] public function __construct()
- {
- $this->organizations = new ArrayCollection();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getName(): ?string
- {
- return $this->name;
- }
- public function setName(?string $name): self
- {
- $this->name = $name;
- return $this;
- }
- public function getCategory(): ?string
- {
- return $this->category;
- }
- public function setCategory(?string $category): self
- {
- $this->category = $category;
- return $this;
- }
- public function getOrganizations(): Collection
- {
- return $this->organizations;
- }
- public function addOrganization(Organization $organization): self
- {
- if (!$this->organizations->contains($organization)) {
- $this->organizations[] = $organization;
- $organization->addTypeOfPractice($this);
- }
- return $this;
- }
- public function removeOrganization(Organization $organization): self
- {
- if ($this->organizations->removeElement($organization)) {
- $organization->removeTypeOfPractice($this);
- }
- return $this;
- }
- }
|