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


PHP Uri::valueOf方法代码示例

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


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

示例1: testDispatch

 /**
  * @test
  * @profile
  */
 public function testDispatch()
 {
     split_time('reset');
     Rest_Test_Unit_Case_Resource_Foo::serve('resource/foo');
     split_time('Invoke Rest_Test_Unit_Case_Resource_Foo::serve(resource/foo)');
     Http_Scriptlet_Context::push(new Http_Scriptlet_Context(Environment::uriComponents()));
     split_time('Initialize Components\\Http_Scriptlet_Context');
     $uri = Uri::valueOf(Environment::uriComponents('rest', 'resource', 'foo', 'poke', '1234.json'));
     split_time("Invoke Uri::valueOf({$uri})");
     ob_start();
     split_time('reset');
     Http_Scriptlet_Context::current()->dispatch($uri, Http_Scriptlet_Request::METHOD_GET);
     split_time("Invoke Components\\Http_Scriptlet_Context\$dispatch([{$uri}], GET)");
     $result = ob_get_clean();
     assertEquals(json_encode(true), $result);
     split_time('reset');
     $uri = Uri::valueOf(Environment::uriComponents('rest', 'resource', 'foo', 'poke', '1234.json'));
     $uri->setQueryParam('log', 'false');
     split_time("Invoke Uri::valueOf({$uri})");
     ob_start();
     split_time('reset');
     Http_Scriptlet_Context::current()->dispatch($uri, Http_Scriptlet_Request::METHOD_GET);
     split_time("Invoke Components\\Http_Scriptlet_Context\$dispatch([{$uri}], GET)");
     $result = ob_get_clean();
     assertEquals(json_encode(false), $result);
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.rest,代码行数:30,代码来源:resource.php

示例2: uri

 /**
  * @param \Components\Io_Image $image_
  *
  * @return \Components\Uri
  */
 public static function uri(Io_Image $image_)
 {
     $path = $image_->getPathAsString();
     $extension = $image_->getMimetype()->fileExtension();
     $key = md5($path);
     Cache::set($key, $path);
     return Uri::valueOf(Environment::uriComponents('ui', 'image', "{$key}.{$extension}"));
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.ui,代码行数:13,代码来源:image.php

示例3: configure

 public function configure(array $resourceIdentifiers_)
 {
     foreach ($resourceIdentifiers_ as $resourceIdentifier) {
         $uri = Uri::valueOf($resourceIdentifier);
         $resource = $uri->getResource();
         if (!$resource instanceof Persistence_Resource) {
             throw new Exception_IllegalArgument('persistence/resource/pool', 'Resource for given identifier is not a valid persistence resource.');
         }
         $this->m_read[] = $resource;
         if (!$resource->isReadOnly()) {
             $this->m_write[] = $resource;
         }
     }
     $this->resource = $this->m_write[rand(0, count($this->m_write) - 1)];
     $this->resourceReadOnly = $this->m_read[rand(0, count($this->m_read) - 1)];
     if (!$this->resource) {
         $this->resource = $this->resourceReadOnly;
     }
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.persistence,代码行数:19,代码来源:pool.php

示例4: dispatchImpl

 private function dispatchImpl(Uri $uri_, $method_ = null)
 {
     $this->m_contextUri = Uri::valueOf($this->m_contextRoot);
     $this->m_request = new Http_Scriptlet_Request(clone $uri_);
     if (null !== $method_) {
         $this->m_request->setMethod($method_);
     }
     $mimeType = $this->m_request->getMimetype();
     header('Content-Type: ' . $mimeType->name() . ';charset=' . $mimeType->charset()->name(), true, 200);
     $this->m_response = new Http_Scriptlet_Response($mimeType);
     if ('/' !== $this->m_contextRoot) {
         $contextRoot = rtrim($this->m_contextRoot, '/');
         $contextRoot = ltrim($contextRoot, '/');
         $contextRootSegments = explode('/', $contextRoot);
         while (count($contextRootSegments)) {
             if (array_shift($contextRootSegments) !== $uri_->shiftPathParam()) {
                 throw new Http_Exception('http/scriptlet/context', null, Http_Exception::NOT_FOUND);
             }
         }
     }
     if (!($component = $uri_->shiftPathParam())) {
         throw new Http_Exception('http/scriptlet/context', null, Http_Exception::NOT_FOUND);
     }
     $this->m_contextUri->pushPathParam($component);
     if ($this->m_contextUri->hasFileExtension()) {
         Config::get($this->m_contextUri->getFilename(true));
     } else {
         Config::get($component);
     }
     Http_Scriptlet::dispatch($this, $uri_);
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.http,代码行数:31,代码来源:context.php

示例5: imageUri

 /**
  * @param string $path_
  * @param integer $width_
  * @param integer $height_
  *
  * @return \Components\Uri
  */
 public static function imageUri($route_, Io_Path $path_, $width_ = null, $height_ = null)
 {
     $uri = Uri::valueOf(Http_Router::uri($route_));
     $uri->pushPathParam(\str\encodeBase64Url(json_encode([(string) Io::path(Environment::pathWeb())->getRelativePath($path_), $width_, $height_])) . '.' . Io::fileExtension($path_));
     return $uri;
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.media,代码行数:13,代码来源:engine.php

示例6: toUri

 /**
  * @return \Components\Uri
  */
 public function toUri()
 {
     return Uri::valueOf($this->m_path);
 }
开发者ID:evalcodenet,项目名称:net.evalcode.components.io,代码行数:7,代码来源:path.php


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