本文整理汇总了PHP中Phalcon\Mvc\Url::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Url::get方法的具体用法?PHP Url::get怎么用?PHP Url::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Mvc\Url
的用法示例。
在下文中一共展示了Url::get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGet
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¶ms=one', $url->get('path', array('params' => 'one')));
}
示例2: get
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: get
/**
* @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: get
public function get($uri = null, $args = null, $local = null)
{
return parent::get($uri, $args, $local);
}
示例5: 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');
}
示例6: 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');
}
示例7: generateUrl
/**
* 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: generateUri
/**
* {@inheritdoc}
*/
public function generateUri($name, array $substitutions = [])
{
return $this->url->get(array_merge(['for' => $name], $substitutions));
}