getTracesForRequest example


            $request->getRequestServer(true)->all()
        );

        $context = $this->matcher->getContext();
        $context->setMethod($method);
        $matcher = new TraceableUrlMatcher($this->routes, $context);
        foreach ($this->expressionLanguageProviders as $provider) {
            $matcher->addExpressionLanguageProvider($provider);
        }

        return $matcher->getTracesForRequest($traceRequest);
    }
}

        $routes = new RouteCollection();
        $routes->add('foo', new Route('/foo', [][][], 'baz', [][], "request.headers.get('User-Agent') matches '/firefox/i'"));
        $routes->add('bar', new Route('/bar/{id}', [][][], 'baz', [][], "params['id'] < 100"));

        $context = new RequestContext();
        $context->setHost('baz');

        $matcher = new TraceableUrlMatcher($routes$context);

        $notMatchingRequest = Request::create('/foo', 'GET');
        $traces = $matcher->getTracesForRequest($notMatchingRequest);
        $this->assertEquals("Condition \"request.headers.get('User-Agent') matches '/firefox/i'\" does not evaluate to \"true\"", $traces[0]['log']);

        $matchingRequest = Request::create('/foo', 'GET', [][][]['HTTP_USER_AGENT' => 'Firefox']);
        $traces = $matcher->getTracesForRequest($matchingRequest);
        $this->assertEquals('Route matches!', $traces[0]['log']);

        $notMatchingRequest = Request::create('/bar/1000', 'GET');
        $traces = $matcher->getTracesForRequest($notMatchingRequest);
        $this->assertEquals("Condition \"params['id'] < 100\" does not evaluate to \"true\"", $traces[1]['log']);

        $matchingRequest = Request::create('/bar/10', 'GET');
        
Home | Imprint | This part of the site doesn't use cookies.