本文整理匯總了PHP中Symfony\Component\Routing\RequestContext::hasParameter方法的典型用法代碼示例。如果您正苦於以下問題:PHP RequestContext::hasParameter方法的具體用法?PHP RequestContext::hasParameter怎麽用?PHP RequestContext::hasParameter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Routing\RequestContext
的用法示例。
在下文中一共展示了RequestContext::hasParameter方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testHasParameter
public function testHasParameter()
{
$requestContext = new RequestContext();
$requestContext->setParameters(array('foo' => 'bar'));
$this->assertTrue($requestContext->hasParameter('foo'));
$this->assertFalse($requestContext->hasParameter('baz'));
}
示例2: match
/**
* @inheritDoc
*/
public function match($pathinfo)
{
if ($this->context->hasParameter('page_actions') || "/_" === substr($pathinfo, 0, 2)) {
// some other router before this one should match something:
throw new ResourceNotFoundException();
}
$candidates = $this->repository->getCandidatesForUrl($pathinfo);
foreach ($candidates as $route) {
$this->getContext()->setParameter('page_actions', $route['actions']);
try {
$res = $this->router->match(PageRouteLoader::PATH_PREFIX . substr($pathinfo, strlen($route['url'])));
if ($res) {
$res['_nodeTranslation'] = $route['id'];
return $res;
}
} catch (ResourceNotFoundException $e) {
// noop. try another candidate
}
}
throw new ResourceNotFoundException();
}