當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。