diff --git a/src/AclRepository.php b/src/AclRepository.php index 8d2c827..cd818e3 100644 --- a/src/AclRepository.php +++ b/src/AclRepository.php @@ -27,6 +27,14 @@ class AclRepository */ protected $role; + /** + * @return array + */ + public function getRole () + { + return $this->role; + } + protected $handler; @@ -85,11 +93,12 @@ public function __construct(array $role, array $config = []) } } - $this->handler = function (ServerRequestInterface $requestInterface) { + $this->handler = function (ServerRequestInterface $requestInterface, AclRepository $aclRepo) { + $this-> $route = $requestInterface->getAttribute('route'); if (!empty($route)) { - foreach ($this->role as $role) { - if ($this->isAllowed($role, $route->getPattern())) { + foreach ($aclRepo->getRole() as $role) { + if ($aclRepo->isAllowed($role, $route->getPattern())) { return true; } } @@ -179,7 +188,7 @@ public function __invoke(ServerRequestInterface $requestInterface, ResponseInter } } catch (InvalidArgumentException $iae) { $fn = $this->handler; - $allowed = $fn($requestInterface); + $allowed = $fn($requestInterface, $this->role, $this); } if ($allowed) {