当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::redirect方法代码示例

本文整理汇总了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]);
     }
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:30,代码来源:CleanupController.php

示例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
             }
         }
     }
 }
开发者ID:sydorenkovd,项目名称:Rest-slim-news,代码行数:61,代码来源:Slim.php

示例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);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:17,代码来源:Slim.php

示例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);
 }
开发者ID:xinix-technology,项目名称:bono,代码行数:21,代码来源:Response.php


注:本文中的Slim\Http\Response::redirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。