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


PHP UriFactory::factory方法代码示例

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


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

示例1: discovery

 /**
  * discovery feed url
  * 
  * @param string $type
  * @param string|Zend\Uri\Http $baseUrl
  * @return mixed
  */
 public function discovery($type = null, $baseUrl = null)
 {
     if ($type === 'rss') {
         $xpath = self::XPATH_RSS;
     } else {
         if ($type === 'atom') {
             $xpath = self::XPATH_ATOM;
         } else {
             $xpath = self::XPATH_BOTH;
         }
     }
     if ($links = $this->getResource()->xpath($xpath)) {
         $ret = array();
         foreach ($links as $v) {
             if (isset($baseUrl)) {
                 $uri = UriFactory::factory(current($v->href));
                 $ret[] = (string) $uri->resolve($baseUrl);
             } else {
                 $ret[] = current($v->href);
             }
         }
         return $ret;
     }
     return null;
 }
开发者ID:sasezaki,项目名称:Diggin_Scraper,代码行数:32,代码来源:Autodiscovery.php

示例2: testLocationCanSetDifferentSchemeUriObjects

 /**
  * Test that we can set a redirect to different URI-schemes via a class
  *
  * @param string $uri
  * @param string $expectedClass
  *
  * @dataProvider locationCanSetDifferentSchemeUrisProvider
  */
 public function testLocationCanSetDifferentSchemeUriObjects($uri, $expectedClass)
 {
     $uri = \Zend\Uri\UriFactory::factory($uri);
     $locationHeader = new Location();
     $locationHeader->setUri($uri);
     $this->assertAttributeInstanceof($expectedClass, 'uri', $locationHeader);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:15,代码来源:LocationTest.php

示例3: normalizeUriHttp

 /**
  * Parses, validates and returns a valid Zend\Uri object
  * from given $input.
  *
  * @param   string|Uri\Http $input
  * @return  null|Uri\Http
  * @throws  Exception\RuntimeException
  * @static
  */
 public static function normalizeUriHttp($input)
 {
     // allow null as value
     if ($input === null) {
         return null;
     }
     $uri = $input;
     // Try to cast
     if (!$input instanceof Uri\Http) {
         try {
             $uri = Uri\UriFactory::factory((string) $input);
         } catch (\Exception $e) {
             // wrap exception under Exception object
             throw new Exception\RuntimeException($e->getMessage(), 0, $e);
         }
     }
     // allow only Zend\Uri\Http objects or child classes (not other URI formats)
     if (!$uri instanceof Uri\Http) {
         throw new Exception\RuntimeException(sprintf("%s: Invalid URL %s, only HTTP(S) protocols can be used", __METHOD__, $uri));
     }
     // Validate the URI
     if (!$uri->isValid()) {
         $caller = function () {
             $traces = debug_backtrace();
             if (isset($traces[2])) {
                 return $traces[2]['function'];
             }
             return null;
         };
         throw new Exception\RuntimeException(sprintf('%s (called by %s): invalid URI ("%s") provided', __METHOD__, $caller(), (string) $input));
     }
     return $uri;
 }
开发者ID:robertodormepoco,项目名称:zf2,代码行数:42,代码来源:Utils.php

示例4: getUrl

 /**
  * Generate a redirect URL from the allowable parameters and configured
  * values.
  *
  * @return string
  */
 public function getUrl()
 {
     $params = $this->assembleParams();
     $uri = Uri\UriFactory::factory($this->_consumer->getUserAuthorizationUrl());
     $uri->setQuery($this->_httpUtility->toEncodedQueryString($params));
     return $uri->toString();
 }
开发者ID:navassouza,项目名称:zf2,代码行数:13,代码来源:UserAuthorization.php

示例5: testUri

 public function testUri()
 {
     $uri1 = UriFactory::factory('tcp://192.168.241.21:25000');
     $uri2 = UriFactory::factory('tcp://192.168.241.21:25000');
     $uri3 = UriFactory::factory('tcp://192.168.241.22:25000');
     $uri4 = UriFactory::factory('');
     $uri5 = UriFactory::factory('192.168.241.22');
     $uri6 = UriFactory::factory('//192.168.241.22');
     $uri7 = UriFactory::factory('192.168.241.22:25000');
     #ve($uri7);
     $this->assertEquals($uri1, $uri2);
     $this->assertEquals('tcp://192.168.241.21:25000', $uri1);
     $this->assertEquals('tcp://192.168.241.21:25000', (string) $uri1);
     $this->assertEquals('tcp://192.168.241.22:25000', $uri3);
     $this->assertEquals('tcp://192.168.241.22:25000', (string) $uri3);
     $this->assertEquals('', (string) $uri4);
     $this->assertEquals('192.168.241.22', (string) $uri5);
     $this->assertEquals('', $uri5->getHost());
     $this->assertEquals('//192.168.241.22', (string) $uri6);
     $this->assertEquals('192.168.241.22', $uri6->getHost());
     $this->assertTrue($uri1 == $uri2);
     $this->assertFalse($uri1 == $uri3);
     $this->assertTrue($uri1 ? true : false);
     $this->assertTrue((string) $uri1 ? true : false);
     $this->assertTrue($uri4 ? true : false);
     $this->assertFalse((string) $uri4 ? true : false);
 }
开发者ID:thefox,项目名称:phpchat,代码行数:27,代码来源:UriTest.php

示例6: prepareUri

 /**
  * @param string|Uri $uri
  * @return string
  */
 protected function prepareUri($uri)
 {
     if (!$uri instanceof Uri) {
         $uri = UriFactory::factory($uri);
     }
     $uri->setScheme($this->request->getScheme());
     return $uri->toString();
 }
开发者ID:violetbrick,项目名称:theme,代码行数:12,代码来源:Frontend.php

示例7: __construct

 /**
  * Assigns values to properties relevant to Image
  *
  * @param  DOMElement $dom
  * @return void
  */
 public function __construct(\DOMElement $dom)
 {
     $xpath = new \DOMXPath($dom->ownerDocument);
     $xpath->registerNamespace('az', 'http://webservices.amazon.com/AWSECommerceService/2005-10-05');
     $this->Url = Uri\UriFactory::factory($xpath->query('./az:URL/text()', $dom)->item(0)->data);
     $this->Height = (int) $xpath->query('./az:Height/text()', $dom)->item(0)->data;
     $this->Width = (int) $xpath->query('./az:Width/text()', $dom)->item(0)->data;
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:14,代码来源:Image.php

示例8: testSendPurgeRequestWithException

 public function testSendPurgeRequestWithException()
 {
     $uris[] = UriFactory::factory('')->setHost('127.0.0.1')->setPort(8080)->setScheme('http');
     $this->cacheServer->expects($this->once())->method('getUris')->willReturn($uris);
     $this->socketAdapterMock->method('connect')->willThrowException(new \Zend\Http\Client\Adapter\Exception\RuntimeException());
     $this->loggerMock->expects($this->never())->method('execute');
     $this->loggerMock->expects($this->once())->method('critical');
     $this->assertFalse($this->model->sendPurgeRequest('tags'));
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:9,代码来源:PurgeCacheTest.php

示例9: toQueryString

 /**
  * Cast to HTTP query string
  * 
  * @param  mixed $url 
  * @param  Zend\OAuth\Config $config 
  * @param  null|array $params 
  * @return string
  */
 public function toQueryString($url, Config $config, array $params = null)
 {
     $uri = Uri\UriFactory::factory($url);
     if (!$uri->isValid() || !in_array($uri->getScheme(), array('http', 'https'))) {
         throw new OAuth\Exception('\'' . $url . '\' is not a valid URI');
     }
     $params = $this->_httpUtility->assembleParams($url, $config, $params);
     return $this->_httpUtility->toEncodedQueryString($params);
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:17,代码来源:Access.php

示例10: setUri

 /**
  * Set the URI to use in the request
  *
  * @param  string|Uri\Uri $uri URI for the web service
  * @return RestClient
  */
 public function setUri($uri)
 {
     if ($uri instanceof Uri\Uri) {
         $this->_uri = $uri;
     } else {
         $this->_uri = Uri\UriFactory::factory($uri);
     }
     return $this;
 }
开发者ID:navtis,项目名称:xerxes-pazpar2,代码行数:15,代码来源:RestClient.php

示例11: setupPathController

 public function setupPathController()
 {
     $request = $this->serviceManager->get('Request');
     $uri = UriFactory::factory('http://example.local/path');
     $request->setUri($uri);
     $router = $this->serviceManager->get('HttpRouter');
     $route = Router\Http\Literal::factory(array('route' => '/path', 'defaults' => array('controller' => 'path')));
     $router->addRoute('path', $route);
     $this->application->bootstrap();
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:10,代码来源:DispatchListenerTest.php

示例12: isCorsRequest

 /**
  * Check if the HTTP request is a CORS request by checking if the Origin header is present and that the
  * request URI is not the same as the one in the Origin
  *
  * @param  HttpRequest $request
  * @return bool
  */
 public function isCorsRequest(HttpRequest $request)
 {
     $headers = $request->getHeaders();
     if (!$headers->has('Origin')) {
         return false;
     }
     $originUri = UriFactory::factory($headers->get('Origin')->getFieldValue());
     $requestUri = $request->getUri();
     // According to the spec (http://tools.ietf.org/html/rfc6454#section-4), we should check host, port and scheme
     return !($originUri->getHost() === $requestUri->getHost()) || !($originUri->getPort() === $requestUri->getPort()) || !($originUri->getScheme() === $requestUri->getScheme());
 }
开发者ID:Cyruxx,项目名称:zfr-cors,代码行数:18,代码来源:CorsService.php

示例13: __construct

 public function __construct($url, $apiKey, $sharedSecret, ApiVersion $version, $timeout = 30)
 {
     $this->lastRequest = null;
     $this->apiKey = trim($apiKey);
     $this->signature = hash("sha256", $apiKey . trim($sharedSecret) . time());
     $this->httpClient = new Client();
     $this->httpClient->setOptions(["timeout" => $timeout]);
     UriFactory::registerScheme("https", "hotelbeds\\hotel_api_sdk\\types\\ApiUri");
     $this->apiUri = UriFactory::factory($url);
     $this->apiUri->prepare($version);
 }
开发者ID:cfrancocapo,项目名称:hotel-api-sdk-php,代码行数:11,代码来源:HotelApiClient.php

示例14: buildUrl

 public function buildUrl($endpoint, array $params = [], $baseUrl = null)
 {
     $uri = UriFactory::factory($endpoint);
     if ($baseUrl && !$uri->isAbsolute()) {
         // Convert relative URL to absolute URL using base URL.
         $uri->resolve($baseUrl);
     }
     // Merge query parameters.
     $uri->setQuery(array_merge($this->options->getQueryParameters(), array_merge($uri->getQueryAsArray(), $params)));
     return "{$uri}";
 }
开发者ID:ScriptFUSION,项目名称:Porter,代码行数:11,代码来源:UrlBuilder.php

示例15: setEndpoint

 /**
  * Set SimpleDB endpoint to use
  *
  * @param string|Uri\Uri $endpoint
  * @return SimpleDb
  * @throws Exception\InvalidArgumentException
  */
 public function setEndpoint($endpoint)
 {
     if (!$endpoint instanceof Uri\Uri) {
         $endpoint = Uri\UriFactory::factory($endpoint);
     }
     if (!$endpoint->isValid()) {
         throw new Exception\InvalidArgumentException("Invalid endpoint supplied");
     }
     $this->_endpoint = $endpoint;
     return $this;
 }
开发者ID:no-reply,项目名称:cbpl-vufind,代码行数:18,代码来源:SimpleDb.php


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