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


PHP Request::getResourceUri方法代码示例

本文整理汇总了PHP中Slim\Http\Request::getResourceUri方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getResourceUri方法的具体用法?PHP Request::getResourceUri怎么用?PHP Request::getResourceUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Slim\Http\Request的用法示例。


在下文中一共展示了Request::getResourceUri方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
         $matchedRoutes = $this->router->getMatchedRoutes($this->request->getMethod(), $this->request->getResourceUri());
         foreach ($matchedRoutes as $route) {
             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;
             }
         }
         if (!$dispatched) {
             $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 (\Exception $e) {
         \Log::log_slim_exception($e);
         // Statamic's error logger
         if ($this->config('debug')) {
             throw $e;
         } else {
             try {
                 $this->error($e);
             } catch (\Slim\Exception\Stop $e) {
                 // Do nothing
             }
         }
     }
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:50,代码来源:Slim.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: run

 /**
  * Run application.
  * Find route matching requesst uri and execute associated controller callback, or
  * set 404 variable.
  */
 public function run()
 {
     $display404 = true;
     $uri = $this->request->getResourceUri();
     $method = $this->request->getMethod();
     foreach ($this->routes as $i => $route) {
         if ($route->matches($uri)) {
             if ($route->supportsHttpMethod($method) || $route->supportsHttpMethod("ANY")) {
                 call_user_func_array($route->getCallable(), array_values($route->getParams()));
                 $display404 = false;
             }
         }
     }
     if ($display404) {
         if (is_callable($this->errorHandler)) {
             call_user_func($this->errorHandler);
         } else {
             echo "404 - route not found";
         }
     }
 }
开发者ID:arstropica,项目名称:reputationloop,代码行数:26,代码来源:Router.php

示例4: getRequestPaths

 public static function getRequestPaths(\Slim\Http\Request $request)
 {
     $basePath = $request->getRootUri();
     if ($basePath === '' || substr($basePath, -1) != '/') {
         $basePath .= '/';
     }
     $host = $request->getHost();
     $protocol = $request->getScheme();
     $requestUri = $request->getRootUri() . $request->getResourceUri();
     return array('basePath' => $basePath, 'host' => $host, 'protocol' => $protocol, 'fullBasePath' => $protocol . '://' . $host . $basePath, 'requestUri' => $requestUri, 'fullUri' => $protocol . '://' . $host . $requestUri);
 }
开发者ID:jenky,项目名称:serapia,代码行数:11,代码来源:Application.php


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