當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Uri::getPathParams方法代碼示例

本文整理匯總了PHP中Uri::getPathParams方法的典型用法代碼示例。如果您正苦於以下問題:PHP Uri::getPathParams方法的具體用法?PHP Uri::getPathParams怎麽用?PHP Uri::getPathParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Uri的用法示例。


在下文中一共展示了Uri::getPathParams方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: dispatch

 public static function dispatch(Http_Scriptlet_Context $context_, Uri $uri_)
 {
     $params = $uri_->getPathParams();
     $storeName = array_shift($params);
     $categoryName = array_shift($params);
     $file = Io::fileUpload();
     $store = Media::store($storeName);
     $store->add($file, $file->getName(), $categoryName);
     // TODO JSON
     echo $store->uri($file->getName(), $categoryName);
 }
開發者ID:evalcodenet,項目名稱:net.evalcode.components.media,代碼行數:11,代碼來源:upload.php

示例2: dispatch

 /**
  * @param \Components\Http_Scriptlet_Context $context_
  * @param \Components\Uri $uri_
  */
 public static function dispatch(Http_Scriptlet_Context $context_, Uri $uri_)
 {
     $params = $uri_->getPathParams();
     $base64 = end($params);
     $info = unserialize(\str\decodeBase64Url($base64));
     $path = array_shift($info);
     $id = array_shift($info);
     $category = array_shift($info);
     $scheme = array_shift($info);
     $store = Media::store($path);
     $file = $store->findByScheme($scheme, $id, $category);
     header('Content-Length: ' . $file->getSize()->bytes());
     readfile((string) $file);
 }
開發者ID:evalcodenet,項目名稱:net.evalcode.components.media,代碼行數:18,代碼來源:image.php

示例3: dispatch

 public static function dispatch(Http_Scriptlet_Context $context_, Uri $uri_)
 {
     if (!($method = $uri_->shiftPathParam())) {
         throw new Http_Exception('rest/resource', null, Http_Exception::NOT_FOUND);
     }
     $resource = get_called_class();
     if (null === self::$m_methods || false === isset(self::$m_methods[$resource][$method])) {
         self::initializeMethods();
         if (false === isset(self::$m_methods[$resource][$method])) {
             throw new Http_Exception('rest/resource', null, Http_Exception::NOT_FOUND);
         }
     }
     $method = self::$m_methods[$resource][$method];
     if (false === isset($method['methods'][$context_->getRequest()->getMethod()])) {
         throw new Http_Exception('rest/resource', null, Http_Exception::NOT_FOUND);
     }
     if (isset($method['path']) && count($uri_->getPathParams()) < count($method['path'])) {
         throw new Http_Exception('rest/resource', null, Http_Exception::NOT_FOUND);
     }
     /* @var $resource \Components\Rest_Resource */
     $resource = new $resource();
     $resource->request = $context_->getRequest();
     $resource->response = $context_->getResponse();
     $params = [];
     if (isset($method['path']) || isset($method['query'])) {
         $marshaller = Object_Marshaller::forMimetype($resource->response->getMimetype());
         foreach ($method['path'] as $name => $type) {
             $params[$name] = $marshaller->unmarshal($uri_->shiftPathParam(), $type);
         }
         if (isset($method['query'])) {
             foreach ($method['query'] as $name => $options) {
                 if ($uri_->hasQueryParam($options['name'])) {
                     $params[$name] = $marshaller->unmarshal($uri_->getQueryParam($options['name']), $options['type']);
                 } else {
                     if ($options['value']) {
                         $params[$name] = $marshaller->unmarshal($options['value'], $options['type']);
                     } else {
                         $params[$name] = null;
                     }
                 }
             }
         }
     }
     if ($result = call_user_func_array([$resource, $method['name']], $params)) {
         echo $marshaller->marshal($result);
     }
 }
開發者ID:evalcodenet,項目名稱:net.evalcode.components.rest,代碼行數:47,代碼來源:resource.php

示例4: dispatch

 /**
  * @param \Components\Http_Scriptlet_Context $context_
  * @param \Components\Uri $uri_
  */
 public static function dispatch(Http_Scriptlet_Context $context_, Uri $uri_)
 {
     if (__CLASS__ === get_called_class()) {
         $segments = $uri_->getPathParams(true);
         $count = count($segments);
         $params = [];
         for ($i = $count; 0 < $i; $i--) {
             $path = implode('/', $segments);
             foreach (self::$m_routes as $pattern => $scriptlet) {
                 $matches = [];
                 if (1 === preg_match($pattern, $path, $matches)) {
                     $uri_->setPathParams($params);
                     foreach ($segments as $segment) {
                         $context_->getContextUri()->pushPathParam($segment);
                     }
                     $scriptlet::dispatch($context_, $uri_);
                     return;
                 }
             }
             array_unshift($params, array_pop($segments));
         }
         if (null !== ($scriptlet = self::$m_default)) {
             $scriptlet::dispatch($context_, $uri_);
             return;
         }
     } else {
         $scriptlet = new static();
         $scriptlet->request = $context_->getRequest();
         $scriptlet->response = $context_->getResponse();
         $method = $scriptlet->request->getMethod();
         if (method_exists($scriptlet, strtolower($method))) {
             return $scriptlet->{$method}();
         }
     }
     throw new Http_Exception('http/scriptlet', null, Http_Exception::NOT_FOUND);
 }
開發者ID:evalcodenet,項目名稱:net.evalcode.components.http,代碼行數:40,代碼來源:scriptlet.php


注:本文中的Uri::getPathParams方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。