[ 'method' => 'GET', 'path' => '/students', 'security' => 'is_granted("ROLE_USERS_VIEW")' ], 'cget_admin'=> [ 'method' => 'GET', 'path' => '/admin' ], 'get' ], itemOperations: [ 'get' => [ 'security' => '(is_granted("ROLE_USERS_VIEW") and object.getOrganization().getId() == user.getOrganization().getId()) or (object.getId() == user.getId())' ], 'put' => [ 'security' => 'is_granted("ROLE_USERS") or (object.getId() == user.getId())' ], 'delete' ] )] #[ORM\Entity(repositoryClass: AccessRepository::class)] class Access implements UserInterface { #[ORM\Id] #[ORM\Column] #[ORM\GeneratedValue] private ?int $id = null; #[ORM\Column(options: ['default' => false])] private bool $adminAccess = false; #[ORM\Column(nullable: true)] private ?int $activityYear = null; #[ORM\ManyToOne(cascade: ['persist'])] #[ORM\JoinColumn(nullable: false)] private Person $person; #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] private Organization $organization; #[ORM\Column(type: 'json', length: 4294967295, nullable: true)] private ?array $roles = []; #[Groups(['my_access:input'])] #[ORM\Column(type: 'json', length: 4294967295, nullable: true)] private ?array $setting = []; #[Groups(['my_access:input'])] private array $historical = []; #[ORM\OneToMany(mappedBy: 'access', targetEntity: PersonActivity::class, cascade: ['persist'], orphanRemoval: true)] #[ApiSubresource] private Collection $personActivity; #[ORM\OneToMany(mappedBy: 'access', targetEntity: OrganizationFunction::class, cascade: ['persist'], orphanRemoval: true)] #[ApiSubresource] private Collection $organizationFunction; #[ORM\OneToMany(mappedBy: 'licensee', targetEntity: OrganizationLicence::class, cascade: ['persist'], orphanRemoval: true)] private Collection $organizationLicences; #[ORM\OneToMany(mappedBy: 'access', targetEntity: PersonalizedList::class, cascade: ['persist'], orphanRemoval: true)] private Collection $personalizedLists; #[ORM\ManyToMany(targetEntity: Access::class, mappedBy: 'children', cascade: ['persist'])] private Collection $guardians; #[ORM\ManyToMany(targetEntity: Access::class, inversedBy: 'guardians', cascade: ['persist'])] #[ORM\JoinTable(name: 'children_guardians')] #[ORM\JoinColumn(name: 'guardians_id', referencedColumnName: 'id')] #[ORM\InverseJoinColumn(name: 'children_id', referencedColumnName: 'id')] private Collection $children; #[Pure] public function __construct() { $this->personActivity = new ArrayCollection(); $this->organizationFunction = new ArrayCollection(); $this->organizationLicences = new ArrayCollection(); $this->personalizedLists = new ArrayCollection(); $this->guardians = new ArrayCollection(); $this->children = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getAdminAccess(): ?bool { return $this->adminAccess; } public function setAdminAccess(bool $adminAccess): self { $this->adminAccess = $adminAccess; return $this; } public function getPerson(): ?Person { return $this->person; } public function setPerson(?Person $person): self { $this->person = $person; return $this; } public function getOrganization(): ?Organization { return $this->organization; } public function setOrganization(?Organization $organization): self { $this->organization = $organization; return $this; } public function getActivityYear(): ?int { return $this->activityYear; } public function setActivityYear(?int $activityYear): self { $this->activityYear = $activityYear; return $this; } public function getHistorical(): array { return array_key_exists('historical', $this->setting) && $this->setting['historical'] ? $this->setting['historical'] : ['present' => true]; } public function setHistorical(array $historical): self { if(!$historical['past'] && !$historical['present'] && !$historical['future']) $historical['present'] = true; $this->setting['historical'] = $historical; return $this; } public function setRoles(?array $roles): self { $this->roles = $roles; return $this; } public function getRoles(): ?array { $roles = $this->roles; return array_unique($roles); } public function getPersonActivity(): Collection { return $this->personActivity; } public function addPersonActivity(PersonActivity $personActivity): self { if (!$this->personActivity->contains($personActivity)) { $this->personActivity[] = $personActivity; $personActivity->setAccess($this); } return $this; } public function removePersonActivity(PersonActivity $personActivity): self { if ($this->personActivity->removeElement($personActivity)) { // set the owning side to null (unless already changed) if ($personActivity->getAccess() === $this) { $personActivity->setAccess(null); } } return $this; } public function getOrganizationFunction(): Collection { return $this->organizationFunction; } public function addOrganizationFunction (OrganizationFunction $organizationFunction): self { if (!$this->organizationFunction->contains($organizationFunction)) { $this->organizationFunction[] = $organizationFunction; $organizationFunction->setAccess($this); } return $this; } public function removeOrganizationFunction(OrganizationFunction $organizationFunction): self { if ($this->organizationFunction->removeElement($organizationFunction)) { // set the owning side to null (unless already changed) if ($organizationFunction->getAccess() === $this) { $organizationFunction->setAccess(null); } } return $this; } public function getOrganizationLicences(): Collection { return $this->organizationLicences; } public function addOrganizationLicence(OrganizationLicence $organizationLicence): self { if (!$this->organizationLicences->contains($organizationLicence)) { $this->organizationLicences[] = $organizationLicence; $organizationLicence->setLicensee($this); } return $this; } public function removeOrganizationLicence(OrganizationLicence $organizationLicence): self { if ($this->organizationLicences->removeElement($organizationLicence)) { // set the owning side to null (unless already changed) if ($organizationLicence->getLicensee() === $this) { $organizationLicence->setLicensee(null); } } return $this; } public function getPersonalizedLists(): Collection { return $this->personalizedLists; } public function addPersonalizedList(PersonalizedList $personalizedList): self { if (!$this->personalizedLists->contains($personalizedList)) { $this->personalizedLists[] = $personalizedList; $personalizedList->setAccess($this); } return $this; } public function removePersonalizedList(PersonalizedList $personalizedList): self { if ($this->personalizedLists->removeElement($personalizedList)) { // set the owning side to null (unless already changed) if ($personalizedList->getAccess() === $this) { $personalizedList->setAccess(null); } } return $this; } public function getChildren(): Collection { return $this->children; } public function addChild (Access $access): self { if (!$this->children->contains($access)) { $this->children[] = $access; $access->addGuardian($this); } return $this; } public function removeChild(Access $access): self { if ($this->children->removeElement($access)) { $access->removeGuardian($this); } return $this; } public function getGuardians(): Collection { return $this->guardians; } public function addGuardian(Access $access): self { if (!$this->guardians->contains($access)) { $this->guardians[] = $access; $access->addChild($this); } return $this; } public function removeGuardian(Access $access): self { if ($this->guardians->removeElement($access)) { $access->removeChild($this); } return $this; } #[Pure] public function getUserIdentifier(): string { return $this->person->getUsername(); } public function getPassword() { // TODO: Implement getPassword() method. } public function getSalt() { // TODO: Implement getSalt() method. } public function getUsername() { // TODO: Implement getUsername() method. } public function eraseCredentials() { // TODO: Implement eraseCredentials() method. } }