本文整理汇总了PHP中OpenCloud\Common\Lang::noslash方法的典型用法代码示例。如果您正苦于以下问题:PHP Lang::noslash方法的具体用法?PHP Lang::noslash怎么用?PHP Lang::noslash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenCloud\Common\Lang
的用法示例。
在下文中一共展示了Lang::noslash方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Url
/**
* Returns the URL of the container
*
* @return string
* @param string $subresource not used; required for compatibility
* @throws NoNameError
*/
public function Url($subresource = '')
{
if (!$this->name) {
throw new Exceptions\NoNameError(Lang::translate('Container does not have an identifier'));
}
return Lang::noslash($this->Service()->Url(rawurlencode($this->name)));
}
示例2: __construct
/**
* Called when creating a new Compute service object
*
* _NOTE_ that the order of parameters for this is *different* from the
* parent Service class. This is because the earlier parameters are the
* ones that most typically change, whereas the later ones are not
* modified as often.
*
* @param \OpenCloud\Identity $conn - a connection object
* @param string $serviceRegion - identifies the region of this Compute
* service
* @param string $urltype - identifies the URL type ("publicURL",
* "privateURL")
* @param string $serviceName - identifies the name of the service in the
* catalog
*/
public function __construct(OpenStack $conn, $serviceType, $serviceName, $serviceRegion, $urltype)
{
parent::__construct($conn, $serviceType, $serviceName, $serviceRegion, $urltype);
$this->_url = Lang::noslash(parent::Url());
$this->getLogger()->info(Lang::translate('Initializing Nova...'));
}
示例3: ips
/**
* Returns the IP address block for the Server or for a specific network.
*
* @api
* @param string $network - if supplied, then only the IP(s) for the
* specified network are returned. Otherwise, all IPs are returned.
* @return object
* @throws Exceptions\ServerIpsError
*/
public function ips($network = null)
{
$url = Lang::noslash($this->Url('ips/' . $network));
$response = $this->getClient()->get($url)->send();
$body = Formatter::decode($response);
return isset($body->addresses) ? $body->addresses : (isset($body->network) ? $body->network : (object) array());
}
示例4: url
/**
* Returns the URL of the data object
*
* If the object is new and doesn't have a name, then an exception is
* thrown.
*
* @param string $subresource Not used
* @return string
* @throws NoNameError
*/
public function url($subresource = '')
{
if (!$this->name) {
throw new Exceptions\NoNameError(Lang::translate('Object has no name'));
}
return Lang::noslash($this->container->url()) . '/' . str_replace('%2F', '/', rawurlencode($this->name));
}
示例5: ips
/**
* Returns the IP address block for the Server or for a specific network
*
* @api
* @param string $network - if supplied, then only the IP(s) for
* the specified network are returned. Otherwise, all IPs are returned.
* @return object
* @throws ServerIpsError
*/
public function ips($network = null)
{
$url = Lang::noslash($this->Url('ips/' . $network));
$response = $this->Service()->Request($url);
// @codeCoverageIgnoreStart
if ($response->HttpStatus() >= 300) {
throw new Exceptions\ServerIpsError(sprintf(Lang::translate('Error in Server::ips(), status [%d], response [%s]'), $response->HttpStatus(), $response->HttpBody()));
}
$object = json_decode($response->httpBody());
$this->checkJsonError();
if (isset($object->addresses)) {
return $object->addresses;
} elseif (isset($object->network)) {
return $object->network;
} else {
return new \stdClass();
}
// @codeCoverageIgnoreEnd
}
示例6: Url
/**
* Returns the URL of this object
*
* @api
* @param string $subresource specified subresource
* @return string
*/
public function Url($subresource = 'tokens')
{
return Lang::noslash($this->url) . '/' . $subresource;
}
示例7: getMetaUrl
/**
* Constructs a specified URL from the subresource
*
* Given a subresource (e.g., "extensions"), this constructs the proper
* URL and retrieves the resource.
*
* @param string $resource The resource requested; should NOT have slashes
* at the beginning or end
* @return \stdClass object
*/
private function getMetaUrl($resource)
{
$urlBase = $this->getEndpoint($this->service_type, $this->service_name, $this->service_region, RAXSDK_URL_PUBLIC);
$url = Lang::noslash($urlBase) . '/' . $resource;
$response = $this->request($url);
// check for NOT FOUND response
if ($response->httpStatus() == 404) {
return array();
}
// @codeCoverageIgnoreStart
if ($response->httpStatus() >= 300) {
throw new Exceptions\HttpError(sprintf(Lang::translate('Error accessing [%s] - status [%d], response [%s]'), $urlBase, $response->httpStatus(), $response->httpBody()));
}
// @codeCoverageIgnoreEnd
// we're good; proceed
$object = json_decode($response->httpBody());
$this->checkJsonError();
return $object;
}
示例8: GetMetaUrl
/**
* Constructs a specified URL from the subresource
*
* Given a subresource (e.g., "extensions"), this constructs the proper
* URL and retrieves the resource.
*
* @param string $resource The resource requested; should NOT have slashes
* at the beginning or end
* @return \stdClass object
*/
private function GetMetaUrl($resource)
{
$urlbase = $this->get_endpoint($this->service_type, $this->service_name, $this->service_region, RAXSDK_URL_PUBLIC);
if ($urlbase == '') {
return array();
}
$ext_url = Lang::noslash($urlbase) . '/' . $resource;
$response = $this->Request($ext_url);
// check for NOT FOUND response
if ($response->HttpStatus() == 404) {
return array();
}
// check for error status
if ($response->HttpStatus() >= 300) {
throw new Exceptions\HttpError(sprintf(Lang::translate('Error accessing [%s] - status [%d], response [%s]'), $urlbase, $response->HttpStatus(), $response->HttpBody()));
}
// we're good; proceed
$obj = json_decode($response->HttpBody());
if ($this->CheckJsonError()) {
return false;
}
return $obj;
}
示例9: Url
/**
* Returns the URL of the data object
*
* If the object is new and doesn't have a name, then an exception is
* thrown.
*
* @param string $subresource Not used
* @return string
* @throws NoNameError
*/
public function Url($subresource = '')
{
if (!$this->name) {
throw new Exceptions\NoNameError(Lang::translate('Object has no name'));
}
$this_name = $this->name;
if (gettype($this->name) == 'array') {
$this->name = $this->name['name'];
}
return Lang::noslash($this->container->Url()) . '/' . str_replace('%2F', '/', rawurlencode($this->name));
}
示例10: test_noslash
public function test_noslash()
{
$this->assertEquals(Lang::noslash('String/'), 'String');
$this->assertEquals(Lang::noslash('String'), 'String');
}
示例11: __construct
/**
* Called when creating a new Compute service object
*
* _NOTE_ that the order of parameters for this is *different* from the
* parent Service class. This is because the earlier parameters are the
* ones that most typically change, whereas the later ones are not
* modified as often.
*
* @param \OpenCloud\Identity $conn - a connection object
* @param string $serviceRegion - identifies the region of this Compute
* service
* @param string $urltype - identifies the URL type ("publicURL",
* "privateURL")
* @param string $serviceName - identifies the name of the service in the
* catalog
*/
public function __construct(OpenStack $conn, $serviceType, $serviceName, $serviceRegion, $urltype)
{
$this->debug(Lang::translate('initializing Nova...'));
parent::__construct($conn, $serviceType, $serviceName, $serviceRegion, $urltype);
$this->_url = Lang::noslash(parent::Url());
}