本文整理汇总了PHP中Uri::toString方法的典型用法代码示例。如果您正苦于以下问题:PHP Uri::toString方法的具体用法?PHP Uri::toString怎么用?PHP Uri::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Uri
的用法示例。
在下文中一共展示了Uri::toString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: match
public function match(FilterableUri $uri)
{
/*
* if the URI does not contain the seed, it is not allowed
*/
if (false === stripos($uri->toString(), $this->seed->toString())) {
$uri->setFiltered(true, 'Doesn\'t match base URI');
return true;
}
return false;
}
示例2: rewrite
//.........这里部分代码省略.........
$seo = new Seo($this->registry);
switch ($uri->getVar('route')) {
case 'common/home':
$is_home = true;
break;
case 'product/product':
if ($this->config->get('config_seo_category')) {
if ($uri->getVar('path') and $this->config->get('config_seo_category') == 'last') {
$categories = explode('_', $uri->getVar('path'));
$categories = array(end($categories));
} else {
$categories = array();
$category_id = $seo->getCategoryIdBySortOrder($uri->getVar('product_id'));
if (!is_null($category_id)) {
$categories = $seo->getParentCategoriesIds($category_id);
$categories[] = $category_id;
if ($this->config->get('config_seo_category') == 'last') {
$categories = array(end($categories));
}
}
}
foreach ($categories as $category) {
$alias = $seo->getAlias($category, 'category');
if ($alias) {
$url .= '/' . $alias;
}
}
$uri->delVar('path');
}
if ($uri->getVar('product_id')) {
$alias = $seo->getAlias($uri->getVar('product_id'), 'product');
if ($alias) {
$url .= '/' . $alias;
}
$uri->delVar('product_id');
$uri->delVar('manufacturer_id');
$uri->delVar('path');
$uri->delVar('search');
}
break;
case 'product/category':
if ($uri->getVar('path')) {
$categories = explode('_', $uri->getVar('path'));
foreach ($categories as $category) {
$alias = $seo->getAlias($category, 'category');
if ($alias) {
$url .= '/' . $alias;
}
}
$uri->delVar('path');
}
break;
case 'information/information':
if ($uri->getVar('information_id')) {
$alias = $seo->getAlias($uri->getVar('information_id'), 'information');
if ($alias) {
$url .= '/' . $alias;
}
$uri->delVar('information_id');
}
break;
case 'product/manufacturer/info':
if ($uri->getVar('manufacturer_id')) {
$alias = $seo->getAlias($uri->getVar('manufacturer_id'), 'manufacturer');
if ($alias) {
$url .= '/' . $alias;
}
$uri->delVar('manufacturer_id');
}
break;
default:
if (!$this->seoDisabled($uri->getVar('route'))) {
$url = '/' . $uri->getVar('route');
}
break;
}
$uri->delVar('route');
}
if ($url or $is_home) {
// Add language code to URL
if ($this->config->get('config_seo_lang_code')) {
$url = '/' . $this->session->data['language'] . $url;
}
$uri->delVar('lang');
// Append the suffix if enabled
if ($this->config->get('config_seo_suffix') && !$is_home) {
$url .= '.html';
}
$path = $uri->getPath();
if ($is_home or $this->config->get('config_seo_rewrite')) {
$path = str_replace('index.php/', '', $path);
$path = str_replace('index.php', '', $path);
}
$path .= $url;
$uri->setPath($path);
return $uri->toString();
} else {
return $link;
}
}
示例3: testToString
/**
* @covers MediaCore\Uri::toString
*/
public function testToString()
{
$url = 'http://example.com/path/to/directory?foo=bar&foo=baz';
$uri = new Uri($url);
$this->assertEquals($url, $uri->toString());
}
示例4: testToString
public function testToString()
{
$expected = 'http://user:password@randomhostname:81/this/is/a/path/filename.ext?qs1=one&qs2=two#frag';
$uri = new Uri($expected);
$actual = $uri->toString();
$this->assertEquals($expected, $actual);
$this->assertEquals($expected, (string) $uri);
}
示例5: testSetFragment
public function testSetFragment()
{
$uri = new Uri('http', 'www.yahoo.com', '/', null, 'foo');
$this->assertEquals('foo', $uri->getFragment());
$this->assertEquals('http://www.yahoo.com/#foo', $uri->toString());
}
示例6: cleanUrl
function cleanUrl($raw_url)
{
$uri = new Uri($raw_url);
$uri->removeQueryItem('PHPSESSID');
return $uri->toString(array('protocol', 'user', 'password', 'host', 'port', 'path', 'query'));
}