本文整理匯總了PHP中Phalcon\Mvc\Url::setDI方法的典型用法代碼示例。如果您正苦於以下問題:PHP Url::setDI方法的具體用法?PHP Url::setDI怎麽用?PHP Url::setDI使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Phalcon\Mvc\Url
的用法示例。
在下文中一共展示了Url::setDI方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* @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);
}
示例2: setDI
public function setDI(PhDIInterface $di)
{
parent::setDI($di);
}
示例3: testIssue1960
/**
* @ticket 1960
* @author Vladimir Kolesnikov <vladimir@extrememember.com>
* @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');
}
示例4: testUrlForExternalSite
/**
* Tests the url with external website
*
* @author Nikos Dimopoulos <nikos@phalconphp.com>
* @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');
}