| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Access;
- use ApiPlatform\Core\Annotation\ApiResource;
- use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * Classe ... qui ...
- */
- #[Auditable]
- #[ORM\Entity]
- #[ApiResource(
- collectionOperations:[],
- itemOperations: [
- "get" => ["security" => "is_granted('ROLE_ADMIN')"]
- ]
- )]
- class AccessFamily
- {
- #[ORM\Id]
- #[ORM\Column]
- #[ORM\GeneratedValue]
- private ?int $id = null;
- #[ORM\OneToMany(mappedBy: 'accessFamily', targetEntity: Access::class)]
- private Collection $accesses;
- #[ORM\OneToMany(mappedBy: 'accessFamily', targetEntity: AccessFictionalIntangible::class, cascade: ['persist'], orphanRemoval: true)]
- private $accessFictionalIntangibles;
- public function __construct()
- {
- $this->accesses = new ArrayCollection();
- $this->accessFictionalIntangibles = new ArrayCollection();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- /**
- * @return Collection<int, Access>
- */
- public function getAccesses(): Collection
- {
- return $this->accesses;
- }
- public function addAccess(Access $access): self
- {
- if (!$this->accesses->contains($access)) {
- $this->accesses[] = $access;
- $access->setAccessFamily($this);
- }
- return $this;
- }
- public function removeAccess(Access $access): self
- {
- if ($this->accesses->removeElement($access)) {
- // set the owning side to null (unless already changed)
- if ($access->getAccessFamily() === $this) {
- $access->setAccessFamily(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, AccessFictionalIntangible>
- */
- public function getAccessFictionalIntangibles(): Collection
- {
- return $this->accessFictionalIntangibles;
- }
- public function addAccessFictionalIntangible(AccessFictionalIntangible $accessFictionalIntangible): self
- {
- if (!$this->accessFictionalIntangibles->contains($accessFictionalIntangible)) {
- $this->accessFictionalIntangibles[] = $accessFictionalIntangible;
- $accessFictionalIntangible->setAccessFamily($this);
- }
- return $this;
- }
- public function removeAccessFictionalIntangible(AccessFictionalIntangible $accessFictionalIntangible): self
- {
- if ($this->accessFictionalIntangibles->removeElement($accessFictionalIntangible)) {
- // set the owning side to null (unless already changed)
- if ($accessFictionalIntangible->getAccessFamily() === $this) {
- $accessFictionalIntangible->setAccessFamily(null);
- }
- }
- return $this;
- }
- }
|