Ejemplo n.º 1
0
 /**
  * Parse/expand request parameters and create a fully qualified
  * request uri.
  * @static
  * @param string $servicePath
  * @param string $restPath
  * @param array $params
  * @return string $requestUrl
  */
 static function createRequestUri($servicePath, $restPath, $params)
 {
     $requestUrl = $servicePath . $restPath;
     $uriTemplateVars = array();
     $queryVars = array();
     foreach ($params as $paramName => $paramSpec) {
         // Discovery v1.0 puts the canonical location under the 'location' field.
         if (!isset($paramSpec['location'])) {
             $paramSpec['location'] = $paramSpec['restParameterType'];
         }
         if ($paramSpec['type'] == 'boolean') {
             $paramSpec['value'] = $paramSpec['value'] ? 'true' : 'false';
         }
         if ($paramSpec['location'] == 'path') {
             $uriTemplateVars[$paramName] = $paramSpec['value'];
         } else {
             if (isset($paramSpec['repeated']) && is_array($paramSpec['value'])) {
                 foreach ($paramSpec['value'] as $value) {
                     $queryVars[] = $paramName . '=' . rawurlencode($value);
                 }
             } else {
                 $queryVars[] = $paramName . '=' . rawurlencode($paramSpec['value']);
             }
         }
     }
     if (count($uriTemplateVars)) {
         $uriTemplateParser = new displetretsidx_URI_Template_Parser($requestUrl);
         $requestUrl = $uriTemplateParser->expand($uriTemplateVars);
     }
     //FIXME work around for the the uri template lib which url encodes
     // the @'s & confuses our servers.
     $requestUrl = str_replace('%40', '@', $requestUrl);
     if (count($queryVars)) {
         $requestUrl .= '?' . implode($queryVars, '&');
     }
     return $requestUrl;
 }
Ejemplo n.º 2
0
 public function __construct($template)
 {
     self::$reserved = array_merge(self::$gen_delims, self::$sub_delims);
     self::$reserved_pct = array_merge(self::$gen_delims_pct, self::$sub_delims_pct);
     $this->template = $template;
 }