本文整理汇总了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');
}