Ejemplo n.º 1
0
 /**
  * Expands a URI template
  *
  * @param string $template  URI template
  * @param array  $variables Template variables
  *
  * @return string
  */
 function puzzle_uri_template($template, array $variables)
 {
     if (function_exists('uri_template')) {
         return uri_template($template, $variables);
     }
     static $uriTemplate;
     if (!$uriTemplate) {
         $uriTemplate = new puzzle_UriTemplate();
     }
     return $uriTemplate->expand($template, $variables);
 }
Ejemplo n.º 2
0
 /**
  * @ticket https://github.com/guzzle/guzzle/issues/90
  */
 public function testAllowsNestedArrayExpansion()
 {
     $template = new puzzle_UriTemplate();
     $result = $template->expand('http://example.com{+path}{/segments}{?query,data*,foo*}', array('path' => '/foo/bar', 'segments' => array('one', 'two'), 'query' => 'test', 'data' => array('more' => array('fun', 'ice cream')), 'foo' => array('baz' => array('bar' => 'fizz', 'test' => 'buzz'), 'bam' => 'boo')));
     $this->assertEquals('http://example.com/foo/bar/one,two?query=test&more%5B0%5D=fun&more%5B1%5D=ice%20cream&baz%5Bbar%5D=fizz&baz%5Btest%5D=buzz&bam=boo', $result);
 }