/**
  * @param Router|null $router
  * @param Url|null $url
  */
 public function __construct(Router $router = null, Url $url = null)
 {
     $di = new DI();
     $di->setShared('request', new PhalconRequest());
     if ($router instanceof PhalconRouterInterface) {
         $this->router = $router;
     } elseif ($router === null) {
         $this->router = new Router();
         $this->router->clear();
     } else {
         throw new Exception\RuntimeException('Router has to be an instance of RouterInterface');
     }
     $this->router->setDI($di);
     $di->setShared('router', $this->router);
     if ($url instanceof UrlInterface) {
         $this->url = $url;
     } elseif ($url === null) {
         $this->url = new Url();
         $this->url->setBaseUri('/');
     } else {
         throw new Exception\RuntimeException('Url has to be an instance of UrlInterface');
     }
     $this->url->setDI($di);
 }
Esempio n. 2
0
 public function setDI(PhDIInterface $di)
 {
     parent::setDI($di);
 }
Esempio n. 3
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');
 }
Esempio n. 4
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');
 }