本文整理汇总了PHP中Zend\Mvc\Router\Http\TreeRouteStack::match方法的典型用法代码示例。如果您正苦于以下问题:PHP TreeRouteStack::match方法的具体用法?PHP TreeRouteStack::match怎么用?PHP TreeRouteStack::match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Mvc\Router\Http\TreeRouteStack
的用法示例。
在下文中一共展示了TreeRouteStack::match方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: match
/**
* @inheritDoc
*/
public function match(PsrRequest $request)
{
// Must inject routes prior to matching.
$this->injectRoutes();
$match = $this->zendRouter->match(Psr7ServerRequest::toZend($request, true));
if (null === $match) {
return RouteResult::fromRouteFailure();
}
return $this->marshalSuccessResultFromRouteMatch($match);
}
示例2: match
/**
* Attempt to match an incoming request to a registered route.
*
* @param PsrRequest $request
* @return RouteResult
*/
public function match(PsrRequest $request)
{
$match = $this->zf2Router->match(Psr7ServerRequest::toZend($request, true));
if (null === $match) {
return RouteResult::fromRouteFailure();
}
$allowedMethods = $this->getAllowedMethods($match->getMatchedRouteName());
if (!$this->methodIsAllowed($request->getMethod(), $allowedMethods)) {
return RouteResult::fromRouteFailure($allowedMethods);
}
return $this->marshalSuccessResultFromRouteMatch($match);
}
示例3: match
/**
* Attempt to match an incoming request to a registered route.
*
* @param PsrRequest $request
* @return RouteResult
*/
public function match(PsrRequest $request)
{
$match = $this->zf2Router->match(Psr7ServerRequest::toZend($request, true));
if (null === $match) {
return RouteResult::fromRouteFailure();
}
return $this->marshalSuccessResultFromRouteMatch($match);
}
示例4: match
/**
* match(): defined by \Zend\Mvc\Router\RouteInterface
*
* @see \Zend\Mvc\Router\RouteInterface::match()
* @param Request $request
* @param integer|null $pathOffset
* @param array $options
* @return RouteMatch|null
*/
public function match(Request $request, $pathOffset = null, array $options = array())
{
if ($this->hasTranslator() && $this->isTranslatorEnabled() && !isset($options['translator'])) {
$options['translator'] = $this->getTranslator();
}
if (!isset($options['text_domain'])) {
$options['text_domain'] = $this->getTranslatorTextDomain();
}
return parent::match($request, $pathOffset, $options);
}
示例5: matchUrl
private function matchUrl($url, $urlHelper)
{
$url = 'http://localhost.localdomain' . $url;
$request = new Request();
$request->setUri($url);
$router = new TreeRouteStack();
$router->addRoute('hostname', ['type' => 'hostname', 'options' => ['route' => 'localhost.localdomain'], 'child_routes' => ['resource' => ['type' => 'segment', 'options' => ['route' => '/resource[/:id]']]]]);
$match = $router->match($request);
if ($match instanceof RouteMatch) {
$urlHelper->setRouter($router);
$urlHelper->setRouteMatch($match);
}
return $match;
}
示例6: setUpRouter
public function setUpRouter()
{
if (isset($this->router)) {
return;
}
$this->setUpRequest();
$routes = ['resource' => ['type' => 'Segment', 'options' => ['route' => '/api/resource[/:id]', 'defaults' => ['controller' => 'Api\\RestController']]]];
$this->router = $router = new TreeRouteStack();
$router->addRoutes($routes);
$matches = $router->match($this->request);
if (!$matches instanceof RouteMatch) {
$this->fail('Failed to route!');
}
$this->matches = $matches;
}
示例7: testDefaultParamDoesNotOverrideParam
public function testDefaultParamDoesNotOverrideParam()
{
$stack = new TreeRouteStack();
$stack->setBaseUrl('/foo');
$stack->addRoute('foo', new TestAsset\DummyRouteWithParam());
$stack->setDefaultParam('foo', 'baz');
$this->assertEquals('bar', $stack->match(new Request())->getParam('foo'));
}