本文整理匯總了PHP中Symfony\Bundle\FrameworkBundle\Routing\Router::matchRequest方法的典型用法代碼示例。如果您正苦於以下問題:PHP Router::matchRequest方法的具體用法?PHP Router::matchRequest怎麽用?PHP Router::matchRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Bundle\FrameworkBundle\Routing\Router
的用法示例。
在下文中一共展示了Router::matchRequest方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: onKernelRequest
/**
* @param GetResponseEvent $event
*/
public function onKernelRequest(GetResponseEvent $event)
{
if ($this->locale || $event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
return;
}
// get route name from request
$route = $this->router->matchRequest($event->getRequest());
if (empty($route['_route'])) {
return;
}
$route = $route['_route'];
// go to the install page
if ($route != 'install' && strpos($route, 'install_') !== 0) {
$event->setResponse(new RedirectResponse($this->router->generate('install')));
}
}
示例2: matchRequest
/**
* @param Request $request
* @return array
*/
public function matchRequest(Request $request)
{
if (null !== $this->parent) {
return $this->parent->matchRequest($request);
}
return parent::matchRequest($request);
}
示例3: matchRequest
/**
* Tries to match a request with a set of routes.
*
* If the matcher can not find information, it must throw one of the exceptions documented
* below.
*
* @param Request $request The request to match
*
* @return array An array of parameters
*
* @throws ResourceNotFoundException If no matching resource could be found
* @throws MethodNotAllowedException If a matching resource was found but the request method is not allowed
*/
public function matchRequest(Request $request)
{
try {
$parameters = parent::matchRequest($request);
$canonical = $request->getPathInfo();
} catch (ResourceNotFoundException $e) {
$alias = $this->getAliasRepo()->findOneBy(array('alias' => substr($request->getPathInfo(), 1)));
if (!$alias) {
throw $e;
}
$parameters = $this->getMatcher()->match('/' . $alias->getPath());
$canonical = $alias->getPath();
}
return array_merge($parameters, array('_canonical' => $canonical));
}
示例4: matchRequest
/**
* @param Request $request
* @return array
*/
public function matchRequest(Request $request)
{
$this->setApiVersion();
return parent::matchRequest($this->requestStack->getCurrentRequest());
}
示例5: matchRequest
/**
* {@inheritdoc}
*/
public function matchRequest(Request $request)
{
$match = parent::matchRequest($request);
$this->setMatchContext($match);
return $match;
}
示例6: matchRequest
/**
* @param Request $request
* @return array
*/
public function matchRequest(Request $request)
{
$match = parent::matchRequest($request);
return $this->processMatch($match);
}