本文整理汇总了PHP中GuzzleHttp\Psr7\uri_for函数的典型用法代码示例。如果您正苦于以下问题:PHP uri_for函数的具体用法?PHP uri_for怎么用?PHP uri_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uri_for函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_It_Gets_Public_Uri
public function test_It_Gets_Public_Uri()
{
$this->client->getConfig('base_uri')->shouldBeCalled()->willReturn(uri_for('myopenstack.org:9000/tenantId'));
$this->object->containerName = 'foo';
$this->object->name = 'bar';
$this->assertEquals(uri_for('myopenstack.org:9000/tenantId/foo/bar'), $this->object->getPublicUri());
}
开发者ID:kunalp,项目名称:openstack,代码行数:7,代码来源:ObjectTest.php
示例2: createUri
/**
* {@inheritdoc}
*/
public function createUri($uri) : UriInterface
{
try {
return uri_for($uri);
} catch (Exception $exception) {
throw new DomainException($exception->getMessage(), $exception->getCode(), $exception);
}
}
开发者ID:novuso,项目名称:common-bundle,代码行数:11,代码来源:GuzzleUriFactory.php
示例3: test_it_retrieves_base_http_url
public function test_it_retrieves_base_http_url()
{
$returnedUri = uri_for('http://foo.com');
$this->client->getConfig('base_uri')->shouldBeCalled()->willReturn($returnedUri);
$uri = $this->operator->testBaseUri();
$this->assertInstanceOf(Uri::class, $uri);
$this->assertEquals($returnedUri, $uri);
}
开发者ID:kunalp,项目名称:openstack,代码行数:8,代码来源:OperatorTest.php
示例4: buildUriWithQuery
/**
* @param string $uri
* @param array $query
* @return UriInterface
*/
public function buildUriWithQuery($uri, array $query)
{
// @todo fix this hack. when using build_query booleans are converted to
// 1 or 0 which the API does not accept. this casts bools to their
// string representation
$query = array_filter($query);
foreach ($query as $k => &$v) {
if (is_bool($v)) {
$v = $v ? 'true' : 'false';
}
}
return Psr7\uri_for($uri)->withQuery(Psr7\build_query($query));
}
开发者ID:GoogleCloudPlatform,项目名称:gcloud-php,代码行数:18,代码来源:UriTrait.php
示例5: parse
/**
* Parses a URL into an associative array of Amazon S3 data including:
*
* - bucket: The Amazon S3 bucket (null if none)
* - key: The Amazon S3 key (null if none)
* - path_style: Set to true if using path style, or false if not
* - region: Set to a string if a non-class endpoint is used or null.
*
* @param string|UriInterface $uri
*
* @return array
* @throws \InvalidArgumentException
*/
public function parse($uri)
{
$url = Psr7\uri_for($uri);
if (!$url->getHost()) {
throw new \InvalidArgumentException('No hostname found in URI: ' . $uri);
}
if (!preg_match($this->pattern, $url->getHost(), $matches)) {
return $this->parseCustomEndpoint($url);
}
// Parse the URI based on the matched format (path / virtual)
$result = empty($matches[1]) ? $this->parsePathStyle($url) : $this->parseVirtualHosted($url, $matches);
// Add the region if one was found and not the classic endpoint
$result['region'] = $matches[2] == 'amazonaws' ? null : $matches[2];
return $result;
}
开发者ID:Air-Craft,项目名称:air-craft-www,代码行数:28,代码来源:S3UriParser.php
示例6: makeStack
public function makeStack(CurlHandler $curl, HandlerStack $stack)
{
$stack->setHandler($curl);
$stack->push(function (callable $handler) {
return function (RequestInterface $request, array $options) use($handler) {
$method = $request->getMethod();
$uri = '/' . trim($request->getUri()->getPath(), '/');
$qs = $request->getUri()->getQuery();
if ($qs) {
$qs = '?' . $qs;
}
$header = $this->getAuthenticationHeader($method, $uri);
$request = $request->withHeader('Authentication', $header);
$request = $request->withUri(Psr7\uri_for(static::BASE_URL . $uri . $qs));
return $handler($request, $options);
};
});
return $stack;
}
开发者ID:graphis,项目名称:cookcountycommunityfund,代码行数:19,代码来源:GuzzleConfiguration.php
示例7: get
public static function get($path, $query = [])
{
if (!isset(self::$guzzle)) {
self::initUsingConfigFile();
}
if (is_array($query)) {
$query = self::weedOut($query);
$query = http_build_query($query, null, '&', PHP_QUERY_RFC3986);
$query = preg_replace('/%5[bB]\\d+%5[dD]=/', '=', $query);
}
$response = self::$guzzle->get($path, ['query' => $query]);
switch ($response->getStatusCode()) {
case 200:
return json_decode($response->getBody(), true);
case 404:
return null;
default:
$uri = Psr7\Uri::resolve(Psr7\uri_for(self::$guzzle->getConfig('base_uri')), $path);
$uri = $uri->withQuery($query);
throw new ServerException($response->getStatusCode() . " " . $response->getReasonPhrase() . ". URI: " . $uri);
}
}
开发者ID:dsv-su,项目名称:daisy-api-client-php,代码行数:22,代码来源:Client.php
示例8: testValidatesUri
/**
* @expectedException \InvalidArgumentException
*/
public function testValidatesUri()
{
Psr7\uri_for(array());
}
开发者ID:kirill-konshin,项目名称:psr7,代码行数:7,代码来源:FunctionsTest.php
示例9: downloadObject
/**
* @param array $args
*/
public function downloadObject(array $args = [])
{
$args += ['bucket' => null, 'object' => null, 'generation' => null];
$requestOptions = array_intersect_key($args, ['httpOptions' => null, 'retries' => null]);
$uri = $this->expandUri(self::DOWNLOAD_URI, ['bucket' => $args['bucket'], 'object' => $args['object'], 'query' => ['generation' => $args['generation'], 'alt' => 'media']]);
return $this->requestWrapper->send(new Request('GET', Psr7\uri_for($uri)), $requestOptions)->getBody();
}
开发者ID:GoogleCloudPlatform,项目名称:gcloud-php,代码行数:10,代码来源:Rest.php
示例10: test_it_adds_paths
public function test_it_adds_paths()
{
$uri = Utils::addPaths(uri_for('http://openstack.org/foo'), 'bar', 'baz', '1', '2');
$this->assertInstanceOf(Uri::class, $uri);
$this->assertEquals(uri_for('http://openstack.org/foo/bar/baz/1/2'), $uri);
}
开发者ID:kunalp,项目名称:openstack,代码行数:6,代码来源:UtilsTest.php
示例11: appendPath
public static function appendPath(UriInterface $uri, $path) : UriInterface
{
return uri_for(rtrim((string) $uri, '/') . '/' . $path);
}
开发者ID:php-opencloud,项目名称:common,代码行数:4,代码来源:Utils.php
示例12: withRootUrl
public function withRootUrl($rootUrl)
{
$instance = clone $this;
$instance->defaultRequest = $instance->defaultRequest->withUri(GuzzlePsr7\uri_for($rootUrl));
return $instance;
}
开发者ID:jsor,项目名称:hal-client,代码行数:6,代码来源:HalClient.php
示例13: testCanBeUrlObject
public function testCanBeUrlObject()
{
$config = array_merge($this->minimal, ['authorizationUri' => Psr7\uri_for('https://another/uri')]);
$o = new OAuth2($config);
$this->assertEquals('/uri', $o->buildFullAuthorizationUri()->getPath());
}
开发者ID:knedle,项目名称:twitter-nette-skeleton,代码行数:6,代码来源:OAuth2Test.php
示例14: createUrl
/**
* Create a Guzzle url for the given URI.
*
* @param string $uri
*
* @return Url
*/
protected function createUrl($uri)
{
return Psr7\uri_for($uri);
}
开发者ID:dukt,项目名称:craft-oauth,代码行数:11,代码来源:HmacSha1Signature.php
示例15: testValidatesUri
/**
* @expectedException \InvalidArgumentException
*/
public function testValidatesUri()
{
Psr7\uri_for([]);
}
开发者ID:xcorlett,项目名称:psr7,代码行数:7,代码来源:FunctionsTest.php
示例16: buildUri
private function buildUri($uri, array $config)
{
if (!isset($config['base_uri'])) {
return $uri instanceof UriInterface ? $uri : new Psr7\Uri($uri);
}
return Psr7\Uri::resolve(Psr7\uri_for($config['base_uri']), $uri);
}
开发者ID:Sebascii,项目名称:guzzle,代码行数:7,代码来源:Client.php
示例17: createUri
/**
* {@inheritdoc}
*/
public function createUri($uri)
{
return Psr7\uri_for($uri);
}
开发者ID:php-http,项目名称:message,代码行数:7,代码来源:GuzzleUriFactory.php
示例18: __construct
public function __construct(HttpClient $httpClient = null, Manager $manager = null)
{
$this->httpClient = $httpClient ?: new HttpClient();
$this->manager = $manager ?: new Manager();
$this->baseUri = Psr7\uri_for('http://srazy.info');
}
开发者ID:webuni,项目名称:srazy-api-client,代码行数:6,代码来源:Client.php
示例19: fixUri
private function fixUri(Step $step, $uri)
{
if (!$step->getEndpoint()) {
return $uri;
}
return Psr7\Uri::resolve(Psr7\uri_for($step->getEndpoint()), $uri);
}
开发者ID:stof,项目名称:player,代码行数:7,代码来源:RequestFactory.php
示例20: __construct
/**
* @param Service $api Service API description
* @param string $endpoint Endpoint to connect to
*/
public function __construct(Service $api, $endpoint)
{
$this->api = $api;
$this->endpoint = Psr7\uri_for($endpoint);
}
开发者ID:Afrozaar,项目名称:wp-api-v2-afrozaar-extras,代码行数:9,代码来源:RestSerializer.php
注:本文中的GuzzleHttp\Psr7\uri_for函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论