コード例 #1
0
ファイル: UriTemplateTest.php プロジェクト: blar/uri-template
 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)));
 }
コード例 #2
0
ファイル: Webservice.php プロジェクト: blar/webservice
 /**
  * @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;
 }