Skip to content

Commit

Permalink
Bugfix for custom handler
Browse files Browse the repository at this point in the history
  • Loading branch information
geggleto committed Jan 8, 2016
1 parent 6f68aeb commit fab144d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/AclRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ class AclRepository
*/
protected $role;

/**
* @return array
*/
public function getRole ()
{
return $this->role;
}


protected $handler;

Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit fab144d

Please sign in to comment.