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


PHP Uri\UriFactory類代碼示例

本文整理匯總了PHP中Zend\Uri\UriFactory的典型用法代碼示例。如果您正苦於以下問題:PHP UriFactory類的具體用法?PHP UriFactory怎麽用?PHP UriFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     UriFactory::registerScheme('chrome-extension', 'Zend\\Uri\\Uri');
     if (method_exists($e->getRequest(), 'getHeaders')) {
         $headers = $e->getRequest()->getHeaders();
         if ($headers->has('Origin') && $headers->has('X-Requested-With') && $headers->addHeaderLine('Access-Control-Allow-Methods: PUT, GET, POST, PATCH, DELETE, OPTIONS') && $headers->get('X-Requested-With')->getFieldValue() === 'com.ionicframework.notifycar') {
             //convert to array because get method throw an exception
             $headersArray = $headers->toArray();
             $origin = $headersArray['Origin'];
             if ($origin === 'file://') {
                 unset($headersArray['Origin']);
                 $headers->clearHeaders();
                 $headers->addHeaders($headersArray);
                 //$headers->addHeaderLine('Access-Control-Allow-Methods: PUT, GET, POST, PATCH, DELETE, OPTIONS');
                 //this is a valid uri
                 $headers->addHeaderLine('Origin', 'file://mobile');
             } else {
                 if ($origin === 'chrome-extension') {
                     unset($headersArray['Origin']);
                     $headers->clearHeaders();
                     $headers->addHeaders($headersArray);
                     //$headers->addHeaderLine('Access-Control-Allow-Methods: PUT, GET, POST, PATCH, DELETE, OPTIONS');
                     //this is a valid uri
                     $headers->addHeaderLine('Origin', 'chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop');
                     //$headers->addHeaderLine('Origin', 'chrome-extension://aicmkgpgakddgnaphhhpliifpcfhicfo');
                 }
             }
         }
     }
 }
開發者ID:edimaurolima,項目名稱:CodeOrders-Cursos,代碼行數:33,代碼來源:Module.php

示例2: 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

示例3: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     UriFactory::registerScheme('chrome-extension', 'Zend\\Uri\\Uri');
 }
開發者ID:paulobezerra,項目名稱:apigility_curso,代碼行數:7,代碼來源:Module.php

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: onBootstrap

 public function onBootstrap(MvcEvent $mvcEvent)
 {
     UriFactory::registerScheme('chrome-extension', 'Zend\\Uri\\Uri');
     // add chrome-extension for API Client
     $serviceManager = $mvcEvent->getApplication()->getServiceManager();
     $eventManager = $mvcEvent->getApplication()->getEventManager();
     $sharedEventManager = $eventManager->getSharedManager();
 }
開發者ID:aqilix,項目名稱:i-experts-apigility-oauth2-doctrine,代碼行數:8,代碼來源:Module.php

示例9: 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

示例10: __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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $this->services = $e->getApplication()->getServiceManager();
     $eventManager->attach(MvcAuthEvent::EVENT_AUTHENTICATION, $this->services->get('DotUser\\Authentication\\AuthenticationListener'), 100);
     $eventManager->attach(MvcEvent::EVENT_ROUTE, $this->services->get('DotUser\\Authentication\\OauthRouteGuard'));
     UriFactory::registerScheme('chrome-extension', 'Zend\\Uri\\Uri');
     $this->fixBrokenOriginHeader($e->getRequest());
 }
開發者ID:n3vrax,項目名稱:dotkernel,代碼行數:11,代碼來源:Module.php


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