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


PHP Url::factory方法代码示例

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


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

示例1: fromResponse

 /**
  * Factory method that instantiates an object from a Response object.
  *
  * @param Response         $response
  * @param ServiceInterface $service
  * @return static
  */
 public static function fromResponse(Response $response, ServiceInterface $service)
 {
     $self = parent::fromResponse($response, $service);
     $segments = Url::factory($response->getEffectiveUrl())->getPathSegments();
     $self->name = end($segments);
     return $self;
 }
开发者ID:dangermark,项目名称:chameleonlabs,代码行数:14,代码来源:Container.php

示例2: testCreatesPresignedUrlsWithStrtotime

 public function testCreatesPresignedUrlsWithStrtotime()
 {
     /** @var $client S3Client */
     $client = $this->getServiceBuilder()->get('s3');
     $url = Url::factory($client->createPresignedUrl($client->get('/foobar'), '10 minutes'));
     $this->assertTrue(time() < $url->getQuery()->get('Expires'));
 }
开发者ID:cstuder,项目名称:nagios-plugins,代码行数:7,代码来源:S3ClientTest.php

示例3: getDescriptionUrl

 /**
  * Get description URL
  *
  * @return Url
  */
 public function getDescriptionUrl()
 {
     if (is_null($this->descriptionUrl)) {
         return Url::factory(SsdpInterface::DEFAULT_DESCRIPTION_URL);
     }
     return $this->descriptionUrl;
 }
开发者ID:T-REX-XP,项目名称:SSDPFinder,代码行数:12,代码来源:AbstractMessage.php

示例4: onOpen

 /**
  * {@inheritdoc}
  * @throws \UnexpectedValueException If a controller is not \Ratchet\Http\HttpServerInterface
  */
 public function onOpen(ConnectionInterface $conn, RequestInterface $request = null)
 {
     if (null === $request) {
         throw new \UnexpectedValueException('$request can not be null');
     }
     $context = $this->_matcher->getContext();
     $context->setMethod($request->getMethod());
     $context->setHost($request->getHost());
     try {
         $route = $this->_matcher->match($request->getPath());
     } catch (MethodNotAllowedException $nae) {
         return $this->close($conn, 403);
     } catch (ResourceNotFoundException $nfe) {
         return $this->close($conn, 404);
     }
     if (is_string($route['_controller']) && class_exists($route['_controller'])) {
         $route['_controller'] = new $route['_controller']();
     }
     if (!$route['_controller'] instanceof HttpServerInterface) {
         throw new \UnexpectedValueException('All routes must implement Ratchet\\Http\\HttpServerInterface');
     }
     $parameters = array();
     foreach ($route as $key => $value) {
         if (is_string($key) && '_' !== substr($key, 0, 1)) {
             $parameters[$key] = $value;
         }
     }
     $url = Url::factory($request->getPath());
     $url->setQuery($parameters);
     $request->setUrl($url);
     $conn->controller = $route['_controller'];
     $conn->controller->onOpen($conn, $request);
 }
开发者ID:igez,项目名称:gaiaehr,代码行数:37,代码来源:Router.php

示例5: onOpen

 /**
  * {@inheritdoc}
  */
 public function onOpen(ConnectionInterface $conn, RequestInterface $request = null)
 {
     if (null === $request) {
         throw new \UnexpectedValueException('$request can not be null');
     }
     $context = $this->_matcher->getContext();
     $context->setMethod($request->getMethod());
     $context->setHost($request->getHost());
     try {
         $parameters = $this->_matcher->match($request->getPath());
     } catch (MethodNotAllowedException $nae) {
         return $this->close($conn, 403);
     } catch (ResourceNotFoundException $nfe) {
         return $this->close($conn, 404);
     }
     if ($parameters['_controller'] instanceof ServingCapableInterface) {
         $parameters['_controller']->serve($conn, $request, $parameters);
     } else {
         $query = array();
         foreach ($query as $key => $value) {
             if (is_string($key) && '_' !== substr($key, 0, 1)) {
                 $query[$key] = $value;
             }
         }
         $url = Url::factory($request->getPath());
         $url->setQuery($query);
         $request->setUrl($url);
         $conn->controller = $parameters['_controller'];
         $conn->controller->onOpen($conn, $request);
     }
 }
开发者ID:owlycode,项目名称:reactboard,代码行数:34,代码来源:RachetRouter.php

示例6: __construct

 /**
  * @param string $baseUrl
  * @param ConsumerCredentials $consumer
  * @param TokenCredentials $tokenCredentials
  */
 public function __construct($baseUrl, ConsumerCredentials $consumerCredentials, TokenCredentials $tokenCredentials = null)
 {
     // @todo check type of $baseUrl
     $this->baseUrl = Url::factory($baseUrl);
     $this->consumerCredentials = $consumerCredentials;
     $this->tokenCredentials = $tokenCredentials;
 }
开发者ID:cultuurnet,项目名称:auth,代码行数:12,代码来源:OAuthProtectedService.php

示例7: testEstimatingTemplateCostMarshalsDataCorrectly

 public function testEstimatingTemplateCostMarshalsDataCorrectly()
 {
     self::log('Estimate a template\'s cost.');
     $result = $this->client->estimateTemplateCost(array('TemplateBody' => file_get_contents(__DIR__ . '/template.json'), 'Parameters' => array(array('ParameterKey' => 'KeyName', 'ParameterValue' => 'keypair-name'))));
     $url = Url::factory($result->get('Url'));
     $this->assertEquals('calculator.s3.amazonaws.com', $url->getHost());
 }
开发者ID:cstuder,项目名称:nagios-plugins,代码行数:7,代码来源:IntegrationTest.php

示例8: getUrl

 /**
  * Returns the URL of the metadata (key or block)
  *
  * @return string
  * @param string $subresource not used; required for strict compatibility
  * @throws ServerUrlerror
  */
 public function getUrl($path = null, array $query = array())
 {
     if (!isset($this->url)) {
         throw new Exceptions\ServerUrlError('Metadata has no URL (new object)');
     }
     return Url::factory($this->url)->addPath($this->key);
 }
开发者ID:huhugon,项目名称:sso,代码行数:14,代码来源:ServerMetadata.php

示例9: generateUrl

 private function generateUrl($pathfile, array $entry)
 {
     $path = substr($pathfile, strlen($entry['directory']));
     $hexTime = dechex(time() + 3600);
     $token = md5($entry['passphrase'] . $path . $hexTime);
     return Url::factory($entry['mount-point'] . '/' . $token . "/" . $hexTime . $path);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:7,代码来源:Apache.php

示例10: testParseCookie

 /**
  * @dataProvider cookieParserDataProvider
  */
 public function testParseCookie($cookie, $parsed, $url = null)
 {
     $c = $this->cookieParserClass;
     $parser = new $c();
     $request = null;
     if ($url) {
         $url = Url::factory($url);
         $host = $url->getHost();
         $path = $url->getPath();
     } else {
         $host = '';
         $path = '';
     }
     foreach ((array) $cookie as $c) {
         $p = $parser->parseCookie($c, $host, $path);
         // Remove expires values from the assertion if they are relatively equal by allowing a 5 minute difference
         if ($p['expires'] != $parsed['expires']) {
             if (abs($p['expires'] - $parsed['expires']) < 300) {
                 unset($p['expires']);
                 unset($parsed['expires']);
             }
         }
         if (is_array($parsed)) {
             foreach ($parsed as $key => $value) {
                 $this->assertEquals($parsed[$key], $p[$key], 'Comparing ' . $key . ' ' . var_export($value, true) . ' : ' . var_export($parsed, true) . ' | ' . var_export($p, true));
             }
             foreach ($p as $key => $value) {
                 $this->assertEquals($p[$key], $parsed[$key], 'Comparing ' . $key . ' ' . var_export($value, true) . ' : ' . var_export($parsed, true) . ' | ' . var_export($p, true));
             }
         } else {
             $this->assertEquals($parsed, $p);
         }
     }
 }
开发者ID:bryon-czoch,项目名称:eBay-CLI,代码行数:37,代码来源:CookieParserProvider.php

示例11: createRedirectRequest

 protected function createRedirectRequest(RequestInterface $request, $statusCode, $location, RequestInterface $original)
 {
     $redirectRequest = null;
     $strict = $original->getParams()->get(self::STRICT_REDIRECTS);
     if ($request instanceof EntityEnclosingRequestInterface && ($statusCode == 303 || !$strict && $statusCode <= 302)) {
         $redirectRequest = RequestFactory::getInstance()->cloneRequestWithMethod($request, 'GET');
     } else {
         $redirectRequest = clone $request;
     }
     $redirectRequest->setIsRedirect(true);
     $redirectRequest->setResponseBody($request->getResponseBody());
     $location = Url::factory($location);
     if (!$location->isAbsolute()) {
         $originalUrl = $redirectRequest->getUrl(true);
         $originalUrl->getQuery()->clear();
         $location = $originalUrl->combine((string) $location, true);
     }
     $redirectRequest->setUrl($location);
     $redirectRequest->getEventDispatcher()->addListener('request.before_send', $func = function ($e) use(&$func, $request, $redirectRequest) {
         $redirectRequest->getEventDispatcher()->removeListener('request.before_send', $func);
         $e['request']->getParams()->set(RedirectPlugin::PARENT_REQUEST, $request);
     });
     if ($redirectRequest instanceof EntityEnclosingRequestInterface && $redirectRequest->getBody()) {
         $body = $redirectRequest->getBody();
         if ($body->ftell() && !$body->rewind()) {
             throw new CouldNotRewindStreamException('Unable to rewind the non-seekable entity body of the request after redirecting. cURL probably ' . 'sent part of body before the redirect occurred. Try adding acustom rewind function using on the ' . 'entity body of the request using setRewindFunction().');
         }
     }
     return $redirectRequest;
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:30,代码来源:RedirectPlugin.php

示例12: __construct

  /**
   * @param string $url
   * @param string $username
   * @param string $password
   * @throws NuxeoClientException
   */
  public function __construct($url = 'http://localhost:8080/nuxeo', $username = 'Administrator', $password = 'Administrator') {
    try {
      $this->baseUrl = Url::factory($url);
      $this->httpClient = new Client($url, array(
        Client::REQUEST_OPTIONS => array(
          'headers' => array(
            'Content-Type' => 'application/json+nxrequest'
          )
        )
      ));
    } catch(GuzzleException $ex) {
      throw NuxeoClientException::fromPrevious($ex);
    }

    $this->httpClient->setRequestFactory(new RequestFactory());

    $self = $this;

    /**
     * @param RequestInterface $request
     */
    $this->interceptors[] = function($request) use ($self, $username, $password) {
      try {
        $request->setAuth($username, $password);
      } catch(GuzzleException $ex) {
        throw NuxeoClientException::fromPrevious($ex);
      }
    };

  }
开发者ID:nuxeo,项目名称:nuxeo-automation-php-client,代码行数:36,代码来源:NuxeoClient.php

示例13: fromString

 /**
  * Create response from string
  *
  * @param string $string
  *
  * @return $this
  */
 public static function fromString($string)
 {
     /** @var Discover $message */
     $message = new static();
     foreach (explode(PHP_EOL, trim($string)) as $line) {
         $tuple = explode(':', trim($line), 2);
         if (2 == count($tuple)) {
             $value = trim(array_pop($tuple));
             switch (strtoupper(array_pop($tuple))) {
                 case 'CACHE-CONTROL':
                     $message->setLifetime(intval(substr($value, strpos($value, '=') + 1)));
                     break;
                 case 'DATE':
                     $message->setDate(new DateTime($value));
                     break;
                 case 'LOCATION':
                     $message->setDescriptionUrl(Url::factory($value));
                     break;
                 case 'SERVER':
                     $message->setServerString($value);
                     break;
                 case 'ST':
                     $message->setSearchTarget(SearchTarget::fromString($value));
                     break;
                 case 'USN':
                     $message->setUniqueServiceName(UniqueServiceName::fromString($value));
                     break;
             }
         }
     }
     return $message;
 }
开发者ID:T-REX-XP,项目名称:SSDPFinder,代码行数:39,代码来源:Discover.php

示例14: testCreatesPutRequests

 public function testCreatesPutRequests()
 {
     // Test using a string
     $request = RequestFactory::getInstance()->create('PUT', 'http://www.google.com/path?q=1&v=2', null, 'Data');
     $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
     $this->assertEquals('PUT', $request->getMethod());
     $this->assertEquals('http', $request->getScheme());
     $this->assertEquals('http://www.google.com/path?q=1&v=2', $request->getUrl());
     $this->assertEquals('www.google.com', $request->getHost());
     $this->assertEquals('/path', $request->getPath());
     $this->assertEquals('/path?q=1&v=2', $request->getResource());
     $this->assertInstanceOf('Guzzle\\Http\\EntityBody', $request->getBody());
     $this->assertEquals('Data', (string) $request->getBody());
     unset($request);
     // Test using an EntityBody
     $request = RequestFactory::getInstance()->create('PUT', 'http://www.google.com/path?q=1&v=2', null, EntityBody::factory('Data'));
     $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
     $this->assertEquals('Data', (string) $request->getBody());
     // Test using a resource
     $resource = fopen('php://temp', 'w+');
     fwrite($resource, 'Data');
     $request = RequestFactory::getInstance()->create('PUT', 'http://www.google.com/path?q=1&v=2', null, $resource);
     $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
     $this->assertEquals('Data', (string) $request->getBody());
     // Test using an object that can be cast as a string
     $request = RequestFactory::getInstance()->create('PUT', 'http://www.google.com/path?q=1&v=2', null, Url::factory('http://www.example.com/'));
     $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
     $this->assertEquals('http://www.example.com/', (string) $request->getBody());
 }
开发者ID:mickdane,项目名称:zidisha,代码行数:29,代码来源:RequestFactoryTest.php

示例15: __construct

 public function __construct($uri = NULL)
 {
     if (empty($uri)) {
         $uri = $this::DEFAULT_URI;
     }
     $this->uri = Url::factory($uri);
 }
开发者ID:joelpittet,项目名称:dopatchutils,代码行数:7,代码来源:RtbcQueue.php


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