Ejemplo n.º 1
0
 public function testFragmentPlaceholder()
 {
     $template = new UriTemplate('http://www.example.com/foo/bar{#foo,bar}');
     $this->assertEquals('http://www.example.com/foo/bar', $template->create(array()));
     $this->assertEquals('http://www.example.com/foo/bar#foo=23', $template->create(array('foo' => 23)));
     $this->assertEquals('http://www.example.com/foo/bar#bar=42', $template->create(array('bar' => 42)));
     $this->assertEquals('http://www.example.com/foo/bar#foo=23,bar=42', $template->create(array('foo' => 23, 'bar' => 42)));
 }
Ejemplo n.º 2
0
 /**
  * @param Blar\Http\HttpRequest $request Request.
  * @param Blar\Webservice\WebserviceMethod $method Method.
  * @return self
  */
 protected function prepareRequest($request, $method)
 {
     $templateVariables = new Collection();
     $query = new Query();
     $body = array();
     foreach ($method->getParameters() as $parameter) {
         switch ($parameter->getStyle()) {
             case 'template':
                 $templateVariables->set($parameter->getName(), $parameter->getValue());
                 break;
             case 'query':
                 $query->set($parameter->getName(), $parameter->getValue());
                 break;
             case 'header':
                 $request->getHeaders()->set($parameter->getName(), $parameter->getValue());
                 break;
             case 'body':
                 $body[$parameter->getName()] = $parameter->getValue();
                 break;
         }
     }
     $url = $method->getUrl();
     $template = new UriTemplate($url);
     $url = $template->create($templateVariables);
     $url = new Url($url);
     $url->setQuery($query);
     $request->setUrl($url);
     $request->setBody($body);
     return $this;
 }