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 any way to only find the specific handler, but not handle it?
In simple way, this is original dispatchRequest()
public function dispatchRequest(ServerRequestInterface $request): ResponseInterface { $method = $request->getMethod(); $uri = $request->getUri()->getPath(); $match = $this->dispatch($method, $uri); switch ($match[0]) { case FastRoute::NOT_FOUND: $this->setNotFoundDecoratorMiddleware(); break; case FastRoute::METHOD_NOT_ALLOWED: $allowed = (array) $match[1]; $this->setMethodNotAllowedDecoratorMiddleware($allowed); break; case FastRoute::FOUND: $route = $this->ensureHandlerIsRoute($match[1], $method, $uri)->setVars($match[2]); if ($this->isExtraConditionMatch($route, $request)) { $this->setFoundMiddleware($route); $request = $this->requestWithRouteAttributes($request, $route); break; } $this->setNotFoundDecoratorMiddleware(); break; } return $this->handle($request); }
But I wanna method which return only $match array, without processing. Something like:
$match
public function dispatchAndReturn(ServerRequestInterface $request): array { $method = $request->getMethod(); $uri = $request->getUri()->getPath(); return $this->dispatch($method, $uri); }
The text was updated successfully, but these errors were encountered:
It's util to Clockwork. I created a DataSource to use on Clockwork
<?php namespace App\DataSources; use Clockwork\DataSource\DataSourceInterface; use Clockwork\Request\Request; use League\Route\Dispatcher; use League\Route\Router; // it is also necessary to obtain the array of routes class AppRouter extends Router { public function getData(): array { return $this->routeCollector->getData(); } } class LeagueRouterDataSource implements DataSourceInterface { public function __construct( protected AppRouter $router, protected ServerRequestInterface $request ) { } public function resolve(Request $request) { $request->controller = $this->getController(); } protected function getController() { $data = $this->router->getData(); $dispatcher = new Dispatcher($data); $dispatcher->setStrategy($this->router->getStrategy()); $match = $dispatcher->dispatchAndReturn($this->request); // or // $match = $dispatcher->dispatch($method, $uri); // dispatch method is public and not be necessary create the dispatchAndReturn method $callable = $match[1]->getCallable(); // if use magic method __invoke if (is_object($callable)) { return get_class($callable); } // if use syntax [controller, method] or "controller::method" if (is_array($callable)) { [$controller, $method] = $callable; return get_class($controller) . "@{$method}"; } // if use anonymous function return "Closure"; } }
Sorry, something went wrong.
No branches or pull requests
Is there any way to only find the specific handler, but not handle it?
In simple way, this is original dispatchRequest()
But I wanna method which return only
$match
array, without processing. Something like:The text was updated successfully, but these errors were encountered: