本文整理汇总了PHP中Slim\Http\Response::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::redirect方法的具体用法?PHP Response::redirect怎么用?PHP Response::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slim\Http\Response
的用法示例。
在下文中一共展示了Response::redirect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cleanupOldFiles
public function cleanupOldFiles()
{
$_SESSION['DB_DONE'] = true;
$cleanupList = array_merge($this->pluginFinder->getDummyPlugins(), $this->filesFinder->getCleanupFiles());
$this->cleanupMedia();
if (count($cleanupList) == 0) {
$_SESSION['CLEANUP_DONE'] = true;
$this->response->redirect($this->app->urlFor('done'));
}
if ($this->request->isPost()) {
$result = [];
foreach ($cleanupList as $path) {
$result = array_merge($result, Utils::cleanPath($path));
}
if (count($result) == 0) {
$_SESSION['CLEANUP_DONE'] = true;
$this->response->redirect($this->app->urlFor('done'));
} else {
$result = array_map(function ($path) {
return substr($path, strlen(SW_PATH) + 1);
}, $result);
$this->app->render('cleanup.php', ['cleanupList' => $result, 'error' => true]);
}
} else {
$cleanupList = array_map(function ($path) {
return substr($path, strlen(SW_PATH) + 1);
}, $cleanupList);
$this->app->render('cleanup.php', ['cleanupList' => $cleanupList, 'error' => false]);
}
}
示例2: call
/**
* Call
*
* This method finds and iterates all route objects that match the current request URI.
*/
public function call()
{
try {
if (isset($this->environment['slim.flash'])) {
$this->view()->setData('flash', $this->environment['slim.flash']);
}
$this->applyHook('slim.before');
ob_start();
$this->applyHook('slim.before.router');
$dispatched = false;
$httpMethodsAllowed = array();
$this->router->setResourceUri($this->request->getResourceUri());
$this->router->getMatchedRoutes();
foreach ($this->router as $route) {
if ($route->supportsHttpMethod($this->environment['REQUEST_METHOD'])) {
try {
$this->applyHook('slim.before.dispatch');
$dispatched = $this->router->dispatch($route);
$this->applyHook('slim.after.dispatch');
if ($dispatched) {
break;
}
} catch (\Slim\Exception\Pass $e) {
continue;
}
} else {
$httpMethodsAllowed = array_merge($httpMethodsAllowed, $route->getHttpMethods());
}
}
if (!$dispatched) {
if ($httpMethodsAllowed) {
$this->response['Allow'] = implode(' ', $httpMethodsAllowed);
$this->halt(405, 'HTTP method not allowed for the requested resource. Use one of these instead: ' . implode(', ', $httpMethodsAllowed));
} else {
$this->notFound();
}
}
$this->applyHook('slim.after.router');
$this->stop();
} catch (\Slim\Exception\Stop $e) {
$this->response()->write(ob_get_clean());
$this->applyHook('slim.after');
} catch (\Slim\Exception\RequestSlash $e) {
$this->response->redirect($this->request->getPath() . '/', 301);
} catch (\Exception $e) {
if ($this->config('debug')) {
throw $e;
} else {
try {
$this->error($e);
} catch (\Slim\Exception\Stop $e) {
// Do nothing
}
}
}
}
示例3: redirect
/**
* Redirect
*
* This method immediately redirects to a new URL. By default,
* this issues a 302 Found response; this is considered the default
* generic redirect response. You may also specify another valid
* 3xx status code if you want. This method will automatically set the
* HTTP Location header for you using the URL parameter.
*
* @param string $url The destination URL
* @param int $status The HTTP redirect status code (optional)
*/
public function redirect($url, $status = 302)
{
$this->response->redirect($url, $status);
$this->halt($status);
}
示例4: redirect
/**
* [redirect description]
*
* @param string $url [description]
* @param integer $status [description]
*
* @return [type] [description]
*/
public function redirect($url = ':self', $status = 302)
{
$scheme = parse_url($url, PHP_URL_SCHEME);
if (isset($scheme)) {
return parent::redirect($url, $status);
}
if ($url === ':self') {
$app = \Slim\Slim::getInstance();
$url = $app->request->getResourceUri();
}
$url = \Bono\Helper\URL::site($url);
return parent::redirect($url, $status);
}