예제 #1
0
파일: UrlTest.php 프로젝트: lisong/cphalcon
 public function testGet()
 {
     $url = new Url();
     $url->setBaseUri('http://www.test.com');
     $this->assertEquals('http://www.test.com', $url->get(''));
     $this->assertEquals('http://www.test.com/', $url->get('/'));
     $this->assertEquals('http://www.test.com/path', $url->get('/path'));
     $url->setBaseUri('http://www.test.com/?_url=/');
     $this->assertEquals('http://www.test.com/?_url=/path&params=one', $url->get('path', array('params' => 'one')));
 }
예제 #2
0
 public function get($url = null, $args = null, $local = null)
 {
     //		if ( $args == null ) {
     //			$args = [ ];
     //		}
     //		$a = parent::get( $url, array_merge( [ SITE_ID => "" ], $args ), $local );
     $a = parent::get($url);
     return $a;
 }
예제 #3
0
파일: Url.php 프로젝트: kathynka/Foundation
 /**
  * @param null $uri
  * @param null $args
  * @return string
  */
 public function get($uri = null, $args = null, $local = null)
 {
     if (isset($uri['for'])) {
         $lang = null;
         if (isset($uri[LangRouter::LANG_PARAM])) {
             $lang = $uri[LangRouter::LANG_PARAM];
         }
         $route = $this->getDI()->getRouter()->getRouteByName($uri['for'], $lang);
         if ($route === null) {
             return "notfound";
         } else {
             $paths = $route->getPaths();
             $request = $this->getDI()->getRequest();
             $dispatcher = $this->getDI()->getDispatcher();
             foreach ($paths as $pathKey => $value) {
                 if (!array_key_exists($pathKey, $uri) && $pathKey !== 'for' && $pathKey) {
                     $uri[$pathKey] = $dispatcher->getParam($pathKey) ?: $value;
                 }
             }
             // if query args should be included
             if (!isset($uri['type']) || $uri['type'] !== 'no_query') {
                 if ($args === null) {
                     $args = [];
                 }
                 if ($uri['for'] === 'this') {
                     foreach ($request->get() as $param => $value) {
                         if (!array_key_exists($param, $args) && $param !== '_url' && $param !== 'setLang') {
                             $args[$param] = $value;
                         }
                     }
                 }
             }
             if ($lang !== null) {
                 $uri["for"] = $route->getName();
             }
         }
     }
     return parent::get($uri, $args);
 }
예제 #4
0
파일: Url.php 프로젝트: lisong/cphalcon
 public function get($uri = null, $args = null, $local = null)
 {
     return parent::get($uri, $args, $local);
 }
예제 #5
0
 /**
  * @ticket 1960
  * @author Vladimir Kolesnikov <*****@*****.**>
  * @since 2014-02-02
  */
 public function testIssue1960()
 {
     $url = new \Phalcon\Mvc\Url();
     $url->setDI($this->di);
     $params = 'http://www.google.com/';
     $expected = 'http://www.google.com/';
     $actual = $url->get($params);
     $this->assertEquals($expected, $actual, 'External Site Url not correct');
 }
예제 #6
0
 /**
  * Tests the url with external website
  *
  * @author Nikos Dimopoulos <*****@*****.**>
  * @since  2012-11-29
  */
 public function testUrlForExternalSite()
 {
     $url = new PhUrl();
     $url->setDI($this->di);
     $params = array('for' => 'wikipedia', 'article' => 'Television_news');
     $expected = '/wiki/Television_news';
     $actual = $url->get($params);
     $this->assertEquals($expected, $actual, 'External Site Url not correct');
 }
예제 #7
0
 /**
  * Gets the url
  *
  * @param string[] $queryParams
  *
  * @return string
  */
 private function generateUrl($queryParams)
 {
     $params = $this->getRequest()->getQuery();
     //Remove htaccess mod rewrite query
     if (array_key_exists('_url', $params)) {
         unset($params['_url']);
     }
     //Override with the new parameters
     foreach ($queryParams as $name => $value) {
         $params[$name] = $value;
     }
     $url = new Url();
     return 'https://' . $this->getRequest()->getHttpHost() . substr($url->get($this->getRequest()->getQuery('_url'), $params), 1);
 }
예제 #8
0
 /**
  * {@inheritdoc}
  */
 public function generateUri($name, array $substitutions = [])
 {
     return $this->url->get(array_merge(['for' => $name], $substitutions));
 }