本文整理汇总了PHP中Zend\Uri\Uri::setHost方法的典型用法代码示例。如果您正苦于以下问题:PHP Uri::setHost方法的具体用法?PHP Uri::setHost怎么用?PHP Uri::setHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Uri\Uri
的用法示例。
在下文中一共展示了Uri::setHost方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clearUri
/**
* Get clear uri.
*
* @static
*
* @param \Zend\Uri\Uri $uri
*
* @return boolean|\Zend\Uri\Uri False if uri is not auhorized
*/
public static function clearUri(Uri $uri)
{
if ($uri->getScheme() !== 'http') {
return false;
}
$uri->setHost('www.vimeo.com');
// clear
$uri->setPort(0);
$uri->setUserInfo('');
$uri->setQuery('');
$uri->setFragment('');
return $uri;
}
示例2: clearUri
/**
* Get clear uri.
*
* @static
*
* @param \Zend\Uri\Uri $uri
*
* @return boolean|\Zend\Uri\Uri False if uri is not auhorized
*/
public static function clearUri(Uri $uri)
{
if ($uri->getScheme() !== 'http') {
return false;
}
$query = $uri->getQueryAsArray();
if (empty($query['v'])) {
return false;
}
$uri->setQuery(array('v' => $query['v']));
$uri->setHost('www.youtube.com');
$uri->setPath('/watch');
// clear
$uri->setPort(0);
$uri->setUserInfo('');
$uri->setFragment('');
return $uri;
}
示例3: geocode
/**
* Execute geocoding
*
* @param Request $request
* @return Response
*/
public function geocode(Request $request)
{
if (null === $request) {
throw new Exception\InvalidArgumentException('request');
}
$uri = new Uri();
$uri->setHost(self::GOOGLE_MAPS_APIS_URL);
$uri->setPath(self::GOOGLE_GEOCODING_API_PATH);
$urlParameters = $request->getUrlParameters();
if (null === $urlParameters) {
throw new Exception\RuntimeException('Invalid URL parameters');
}
$uri->setQuery($urlParameters);
$client = $this->getHttpClient();
$client->setAdapter('Zend\\Http\\Client\\Adapter\\Curl');
$client->resetParameters();
$uri->setScheme("https");
$client->setUri($uri->toString());
$stream = $client->send();
$body = Json::decode($stream->getBody(), Json::TYPE_ARRAY);
$hydrator = new ArraySerializable();
$response = new Response();
$response->setRawBody($body);
if (!isset($body['status'])) {
throw new Exception\RuntimeException('Invalid status');
}
$response->setStatus($body['status']);
if (!isset($body['results'])) {
throw new Exception\RuntimeException('Invalid results');
}
$resultSet = new ResultSet();
foreach ($body['results'] as $data) {
$result = new Result();
$hydrator->hydrate($data, $result);
$resultSet->addElement($result);
}
$response->setResults($resultSet);
return $response;
}
示例4: invalidRelativeUriObjectProvider
/**
* Data provider for invalid relative URI objects
*
* @return array
*/
public function invalidRelativeUriObjectProvider()
{
// Empty URI is not valid
$obj1 = new Uri();
// Path cannot begin with '//'
$obj2 = new Uri();
$obj2->setPath('//path');
// A object with port
$obj3 = new Uri();
$obj3->setPort(123);
// A object with userInfo
$obj4 = new Uri();
$obj4->setUserInfo('shahar:password');
// A object with scheme
$obj5 = new Uri();
$obj5->setScheme('https');
// A object with host
$obj6 = new Uri();
$obj6->setHost('example.com');
return array(array($obj1), array($obj2), array($obj3), array($obj4), array($obj5), array($obj6));
}
示例5: testSetNullHost
/**
* Test that we can set the host part to 'null'
*
*/
public function testSetNullHost()
{
$uri = new Uri('http://example.com/bar');
$uri->setHost(null);
$this->assertNull($uri->getHost());
}
示例6: clearUri
/**
* Get clear uri.
*
* @static
*
* @param \Zend\Uri\Uri $uri
*
* @return boolean|\Zend\Uri\Uri False if uri is not auhorized
*/
public static function clearUri(Uri $uri)
{
if ($uri->getScheme() !== 'http') {
return false;
}
$paths = explode('/', $uri->getPath());
$pathsCount = count($paths);
if ($pathsCount < 2) {
return false;
}
$type = $paths[$pathsCount - 2];
if (!in_array($type, self::$typesAuthorized)) {
return false;
}
$uri->setHost('www.deezer.com');
// clear
$uri->setPort(0);
$uri->setUserInfo('');
$uri->setQuery('');
$uri->setFragment('');
return $uri;
}
示例7: setHost
/**
* Set the URI host
*
* @param string $host
* @throws Exception\InvalidUriPartException
* @return \Zend\Uri\Uri
*/
public function setHost($host)
{
$this->uri->setHost($host);
return $this;
}