guessRoute example

/** * @final */
    public function collect(Request $request, Response $response, \Throwable $exception = null): void
    {
        if ($response instanceof RedirectResponse) {
            $this->data['redirect'] = true;
            $this->data['url'] = $response->getTargetUrl();

            if ($this->controllers->contains($request)) {
                $this->data['route'] = $this->guessRoute($request$this->controllers[$request]);
            }
        }

        unset($this->controllers[$request]);
    }

    /** * @return void */
    public function reset()
    {
        
/** * @final */
    public function collect(Request $request, Response $response, \Throwable $exception = null): void
    {
        if ($response instanceof RedirectResponse) {
            $this->data['redirect'] = true;
            $this->data['url'] = $response->getTargetUrl();

            if ($this->controllers->contains($request)) {
                $this->data['route'] = $this->guessRoute($request$this->controllers[$request]);
            }
        }

        unset($this->controllers[$request]);
    }

    /** * @return void */
    public function reset()
    {
        

    public function guessRoute(Request $request, mixed $controller): string
    {
        if (\is_array($controller)) {
            $controller = $controller[0];
        }

        if ($controller instanceof RedirectController) {
            return $request->attributes->get('_route');
        }

        return parent::guessRoute($request$controller);
    }
}
Home | Imprint | This part of the site doesn't use cookies.