0])] protected bool $isAdmin = false; #[ORM\Column(nullable: false, options: ["default" => 0])] protected bool $needsSso = false; public function __construct() { $this->acls = new ArrayCollection(); } public function getRoleId(): string { return (string) $this->getName(); } public function setName(string $name): static { $this->name = $name; return $this; } public function getName(): string { return $this->name; } /** * @return AclResource[] */ public function getResources(): array { return array_map( fn(Acl $acl) => $acl->getResource(), array_filter($this->acls->toArray(), fn(Acl $acl) => $acl->getIsActive()), ); } public function getIsAdmin(): bool { return $this->isAdmin; } public function setIsAdmin(bool $isAdmin): static { $this->isAdmin = $isAdmin; return $this; } public function isAllowed(Resource $resource): bool { if ($this->isAdmin) { return true; } return array_any($this->getResources(), fn(AclResource $_resource) => $_resource->getName() === $resource->getResourceId()); } public function getContext(): ?string { return $this->context; } public function setContext(?string $context): static { $this->context = $context; return $this; } public function getNeedsSso(): bool { return $this->needsSso; } public function setNeedsSso(bool $needsSso): static { $this->needsSso = $needsSso; return $this; } public function getType(): AclRoleTypeEnum { return $this->type; } public function setType(AclRoleTypeEnum $type): static { $this->type = $type; return $this; } }