Skip to content

Commit fab144d

Browse files
committed
Bugfix for custom handler
1 parent 6f68aeb commit fab144d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/AclRepository.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ class AclRepository
2727
*/
2828
protected $role;
2929

30+
/**
31+
* @return array
32+
*/
33+
public function getRole ()
34+
{
35+
return $this->role;
36+
}
37+
3038

3139
protected $handler;
3240

@@ -85,11 +93,12 @@ public function __construct(array $role, array $config = [])
8593
}
8694
}
8795

88-
$this->handler = function (ServerRequestInterface $requestInterface) {
96+
$this->handler = function (ServerRequestInterface $requestInterface, AclRepository $aclRepo) {
97+
$this->
8998
$route = $requestInterface->getAttribute('route');
9099
if (!empty($route)) {
91-
foreach ($this->role as $role) {
92-
if ($this->isAllowed($role, $route->getPattern())) {
100+
foreach ($aclRepo->getRole() as $role) {
101+
if ($aclRepo->isAllowed($role, $route->getPattern())) {
93102
return true;
94103
}
95104
}
@@ -179,7 +188,7 @@ public function __invoke(ServerRequestInterface $requestInterface, ResponseInter
179188
}
180189
} catch (InvalidArgumentException $iae) {
181190
$fn = $this->handler;
182-
$allowed = $fn($requestInterface);
191+
$allowed = $fn($requestInterface, $this->role, $this);
183192
}
184193

185194
if ($allowed) {

0 commit comments

Comments
 (0)