We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a way to pass information to filters?
For example:
$router->get('/client/add', [$controller, 'getAdd'], ['before' => ['permissionCheck', 'client_create']]);
and:
$router->filter('permissionCheck', function($permission) { echo $permission; // client_create });
The text was updated successfully, but these errors were encountered:
Did you got the solution?
Sorry, something went wrong.
Here is my solution. basically i've extended the Dispatcher for store current resolved route and vars.
`use Phroute\Phroute\Dispatcher;
class RouteDispatcher extends Dispatcher{
protected $routeInfo = []; /** * Dispatch a route for the given HTTP Method / URI. * * @param $httpMethod * @param $uri * @return mixed|null */ public function dispatch($httpMethod, $uri) { $dispatchRoute = new \ReflectionMethod($this,'dispatchRoute'); $dispatchRoute->setAccessible(true); $parseFilters = new \ReflectionMethod($this,'parseFilters'); $parseFilters->setAccessible(true); $dispatchFilters = new \ReflectionMethod($this,'dispatchFilters'); $dispatchFilters->setAccessible(true); list($handler, $filters, $vars) = $dispatchRoute->invokeArgs($this,[$httpMethod, trim($uri, '/')]); $this->routeInfo = [ 'uri' => trim($uri,'/'), 'vars' => $vars ]; list($beforeFilter, $afterFilter) = $parseFilters->invokeArgs($this,[$filters]); if(($response = $dispatchFilters->invokeArgs($this,[$beforeFilter])) !== null) { return $response; } $resolvedHandler = $this->handlerResolver->resolve($handler); $response = call_user_func_array($resolvedHandler, $vars); return $dispatchFilters->invokeArgs($this,[$afterFilter, $response]); } public function getRouteInfo(){ return $this->routeInfo; }
`
No branches or pull requests
Is there a way to pass information to filters?
For example:
and:
The text was updated successfully, but these errors were encountered: