| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Person;
- use ApiPlatform\Core\Annotation\ApiResource;
- use App\Entity\Core\AddressPostal;
- use App\Repository\Person\PersonAddressPostalRepository;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Serializer\Annotation\Groups;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * Lien entre une Person et une AddressPostal
- */
- #[ApiResource(
- collectionOperations: [],
- itemOperations: [
- "get" => ["security" => "is_granted('ROLE_USERS_VIEW')"],
- ]
- )]
- #[ORM\Entity(repositoryClass: PersonAddressPostalRepository::class)]
- class PersonAddressPostal
- {
- #[ORM\Id]
- #[ORM\Column]
- #[ORM\GeneratedValue]
- private ?int $id = null;
- #[ORM\ManyToOne(inversedBy: 'personAddressPostal')]
- #[ORM\JoinColumn(nullable: false)]
- private Person $person;
- #[ORM\OneToOne(inversedBy: 'personAddressPostal', cascade: ['persist', 'remove'])]
- #[ORM\JoinColumn(nullable: false)]
- #[Groups("access_address")]
- private AddressPostal $addressPostal;
- #[ORM\Column(length: 255)]
- #[Assert\Choice(callback: ['\App\Enum\Person\AddressPostalPersonTypeEnum', 'toArray'], message: 'invalid-address-postal-type')]
- #[Groups("access_address")]
- private string $type;
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getPerson(): ?Person
- {
- return $this->person;
- }
- public function setPerson(Person $person): self
- {
- $this->person = $person;
- return $this;
- }
- public function getAddressPostal(): ?AddressPostal
- {
- return $this->addressPostal;
- }
- public function setAddressPostal(AddressPostal $addressPostal): self
- {
- $this->addressPostal = $addressPostal;
- return $this;
- }
- public function getType(): string
- {
- return $this->type;
- }
- public function setType(string $type): self
- {
- $this->type = $type;
- return $this;
- }
- }
|