本文整理匯總了PHP中Symfony\Component\HttpFoundation\RedirectResponse::sendHeaders方法的典型用法代碼示例。如果您正苦於以下問題:PHP RedirectResponse::sendHeaders方法的具體用法?PHP RedirectResponse::sendHeaders怎麽用?PHP RedirectResponse::sendHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\HttpFoundation\RedirectResponse
的用法示例。
在下文中一共展示了RedirectResponse::sendHeaders方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: match
/**
* Tries to match a URL path with a set of routes.
*
* If the matcher can not find information, it must throw one of the
* exceptions documented below.
*
* @param string $pathinfo The path info to be parsed (raw format, i.e. not
* urldecoded)
*
* @return array An array of parameters
*
* @throws ResourceNotFoundException If the resource could not be found
* @throws MethodNotAllowedException If the resource was found but the
* request method is not allowed
*/
public function match($pathinfo)
{
$urlMatcher = new UrlMatcher($this->routeCollection, $this->getContext());
$result = $urlMatcher->match($pathinfo);
if (!empty($result)) {
try {
// The route matches, now check if it actually exists
$result['content'] = $this->contentManager->findActiveBySlug($result['slug']);
} catch (NoResultException $e) {
try {
//is it directory index
if (substr($result['slug'], -1) == '/' || $result['slug'] == '') {
$result['content'] = $this->contentManager->findActiveBySlug($result['slug'] . 'index');
} else {
if ($this->contentManager->findActiveBySlug($result['slug'] . '/index')) {
$redirect = new RedirectResponse($this->request->getBaseUrl() . "/" . $result['slug'] . '/');
$redirect->sendHeaders();
exit;
}
}
} catch (NoResultException $ex) {
try {
$result['content'] = $this->contentManager->findActiveByAlias($result['slug']);
} catch (NoResultException $ex) {
throw new ResourceNotFoundException('No page found for slug ' . $pathinfo);
}
}
}
}
return $result;
}
示例2: redirect
/**
* Redirect Response.
*
* @param string $url
* @param int $status
* @param array $headers
*/
public static function redirect($url, $status = 302, $headers = array())
{
$redirect = new RedirectResponse($url, $status, $headers);
$redirect->sendHeaders();
die;
}
示例3: redirect
/**
* (non-PHPdoc)
* @see TheTwelve\Foursquare.Redirector::redirect()
*/
public function redirect($uri)
{
$response = new HttpFoundation\RedirectResponse($uri);
$response->sendHeaders();
return $response;
}