Example #1
0
 public function testSetGetParams()
 {
     $url_parser = new Parser('http://domain.tld/path?param=value#anchor');
     $updated_params = array('param' => 'value', 'new_param' => 'new_value');
     $this->assertEquals(array('param' => 'value'), $url_parser->getParams());
     $url_parser->setParams($updated_params);
     $this->assertEquals($updated_params, $url_parser->getParams());
     $this->assertEquals(http_build_query($updated_params), $url_parser->getComponent('query'));
 }
Example #2
0
 /**
  * Returns normalized url.
  *
  * @param PageUrlAnnotation $annotation The page url annotation.
  *
  * @return array
  */
 public function normalize(PageUrlAnnotation $annotation)
 {
     $parser = new Parser($this->baseUrl);
     $parser->merge(new Parser($annotation->url));
     $parser->setParams(array_merge($parser->getParams(), $annotation->params));
     $ret = $parser->getComponents();
     if ($annotation->secure !== null && !empty($ret['scheme'])) {
         $ret['scheme'] = $annotation->secure ? 'https' : 'http';
     }
     return $ret;
 }