本文整理汇总了PHP中Zend_Uri_Http::setQueryArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Uri_Http::setQueryArray方法的具体用法?PHP Zend_Uri_Http::setQueryArray怎么用?PHP Zend_Uri_Http::setQueryArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Uri_Http
的用法示例。
在下文中一共展示了Zend_Uri_Http::setQueryArray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _prepareRest
/**
* Call a remote REST web service URI and return the Zend_Http_Response object
*
* @param string $path The path to append to the URI
* @throws Zend_Service_Exception
* @return void
*/
private final function _prepareRest($path, $query)
{
// Get the URI object and configure it
if (!$this->_uri instanceof Zend_Uri) {
throw new Zend_Service_Exception('URI object must be set before performing call');
}
// @todo this needs to be revisited
if ($path[0] != '/' && $this->_uri[strlen($this->_uri) - 1] != '/') {
$path = '/' . $path;
}
$this->_uri->setPath($path);
if (!is_null($query) && is_string($query)) {
$this->_uri->setQueryString($query);
} elseif (is_array($query)) {
$this->_uri->setQueryArray($query);
}
/**
* Get the HTTP client and configure it for the endpoint URI. Do this each time
* because the Zend_Http_Client instance is shared among all Zend_Service_Abstract subclasses.
*/
self::getHttpClient()->setUri($this->_uri);
}
示例2: generateUrl
public function generateUrl($parameters, Zend_Uri_Http $url)
{
$parts = $this->getParts();
$n = count($parts);
$path = $parts[0];
for ($i = 1; $i < $n; $i += 3) {
$type = $parts[$i];
$name = $parts[$i + 1];
$static = $parts[$i + 2];
if (isset($parameters[$name])) {
$path .= $this->encode($type, $parameters[$name]);
unset($parameters[$name]);
} else {
if (array_key_exists($name, $this->defaults)) {
if (is_null($this->defaults[$name])) {
// Remove rest of params so they dont appear in querystring
for (; $i < $n; $i += 3) {
unset($parameters[$parts[$i + 1]]);
}
break;
} else {
$path .= $this->encode($type, $this->defaults[$name]);
}
} else {
throw new Zend_Controller_Router_Exception("Missing required parameter {$name}");
}
}
$path .= $static;
}
// Validate the path (and therefore parameters used so far) for this route
if (0 == preg_match($this->getRegularExpression(), $path)) {
throw new Zend_Controller_Router_Exception("{$path} does not match route {$this->getName()} {$this->getRegularExpression()}");
}
// Remove parameters that are at their defaults for this route
if (!empty($this->defaults)) {
$parameters = array_diff_assoc($parameters, $this->defaults);
}
$url->setPath($path);
$url->setQueryArray($parameters);
return $url;
}