本文整理汇总了PHP中Uri::getPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Uri::getPath方法的具体用法?PHP Uri::getPath怎么用?PHP Uri::getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Uri
的用法示例。
在下文中一共展示了Uri::getPath方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPattern
/**
* Returns a pattern representing an uri. It can be used to check if two urls have the same
* equivalence class.
*
* @return string
*/
public function getPattern()
{
// file type
$pattern = $this->getFileType() . ':';
// schema (http, https)
$pattern .= $this->uri->getScheme() . ':';
// host
$pattern .= $this->uri->getHost() . ':';
$path = $this->uri->getPath() . '?' . $this->uri->getQuery();
$pathNew = preg_replace("^[a-f0-9]{32}^", "<h>", $path);
$pathNew = preg_replace("^[a-z\\-\\_]{1,}^i", "<s>", $pathNew);
$pathNew = preg_replace("^[0-9]{1,}^", "<i>", $pathNew);
$pattern .= $pathNew;
return $pattern;
}
示例2: testShouldParseUriWithPortSuccessful
public function testShouldParseUriWithPortSuccessful()
{
$case = 'http://www.example.com:3232/payments/1?foo=bar&baz=bar#order';
$uri = new Uri($case);
$this->assertEquals(3232, $uri->getPort());
$this->assertEquals('www.example.com', $uri->getHost());
$this->assertEquals('http', $uri->getScheme());
$this->assertNotEmpty($uri->getPath());
$this->assertEquals('/payments/1', $uri->getPath());
$this->assertNotEmpty($uri->getQuery());
$this->assertEquals('foo=bar&baz=bar', $uri->getQuery());
$this->assertNotEmpty($uri->getFragment());
$this->assertEquals('order', $uri->getFragment());
$this->assertEquals($case, $uri->__toString());
}
示例3: testConstructor
public function testConstructor()
{
$uri = new Uri('http://user:password@example.com:81/foo/bar?a=2&b=3#baz');
$this->assertEquals('http', $uri->getScheme());
$this->assertEquals('example.com', $uri->getHost());
$this->assertEquals('/foo/bar', $uri->getPath());
$this->assertEquals(81, $uri->getPort());
$this->assertEquals('user:password', $uri->getUserInfo());
$this->assertEquals('a=2&b=3', $uri->getQuery());
$this->assertEquals('baz', $uri->getFragment());
}
示例4: testSetGetPath
public function testSetGetPath()
{
$path = 'this/is/another/path/with-file.other';
$this->uri->setPath($path);
$this->assertEquals($path, $this->uri->getPath());
$this->assertEquals('this/is/another/path', $this->uri->getDirname());
$this->assertEquals('with-file.other', $this->uri->getBasename());
$this->assertEquals('with-file', $this->uri->getFilename());
$this->assertEquals('other', $this->uri->getExtension());
$this->uri->setPath('');
$this->assertEquals('', $this->uri->getDirname());
$this->assertEquals('', $this->uri->getBasename());
$this->assertEquals('', $this->uri->getFilename());
$this->assertEquals('', $this->uri->getExtension());
}
示例5: dispatch
/**
* @param \Components\Http_Scriptlet_Context $context_
* @param \Components\Uri $uri_
*/
public static function dispatch(Http_Scriptlet_Context $context_, Uri $uri_)
{
$uri = $context_->getRequest()->getUri();
$extension = $uri->getFileExtension();
$name = $uri->getFilename(true);
$uri_->popPathParam();
$pathTarget = Environment::pathWeb() . $uri_->getPath() . '/' . \str\decodeUrl($name, true) . ".{$extension}";
if (false === is_file($pathTarget)) {
$fileTarget = Io::file($pathTarget);
$directoryTarget = $fileTarget->getDirectory();
if (false === $directoryTarget->exists()) {
$directoryTarget->create();
}
$info = @json_decode(\str\decodeBase64Url($name));
if (false === isset($info[0])) {
throw new Http_Exception('media/scriptlet/engine', sprintf('Not found [%s].', $uri), Http_Exception::NOT_FOUND);
}
$pathSource = Environment::pathWeb($info[0]);
if (false === is_file($pathSource)) {
throw new Http_Exception('media/scriptlet/engine', sprintf('Not found [%s].', $uri), Http_Exception::NOT_FOUND);
}
if (isset($info[1]) || isset($info[2])) {
if (!isset($info[1])) {
$info[1] = 0;
}
if (!isset($info[2])) {
$info[2] = 0;
}
Io::image($pathSource)->scale(Point::of($info[1], $info[2]))->saveAs($fileTarget);
} else {
Io::file($pathSource)->copy($fileTarget);
}
}
header('Content-Length: ' . Io::fileSize($pathTarget)->bytes());
readfile($pathTarget);
}
示例6: resolve
/**
* @param string $toResolve
* @return Uri
* @link http://tools.ietf.org/html/rfc3986#section-5.2.2
*/
public function resolve($toResolve)
{
$r = new Uri($toResolve);
if ($r->__toString() === '') {
return clone $this;
}
$base = $this;
$t = new \StdClass();
$t->scheme = '';
$t->authority = '';
$t->path = '';
$t->query = '';
$t->fragment = '';
if ('' !== $r->getScheme()) {
$t->scheme = $r->getScheme();
$t->authority = $r->getAuthority();
$t->path = $this->removeDotSegments($r->getPath());
$t->query = $r->getQuery();
} else {
if ('' !== $r->getAuthority()) {
$t->authority = $r->getAuthority();
$t->path = $this->removeDotSegments($r->getPath());
$t->query = $r->getQuery();
} else {
if ('' == $r->getPath()) {
$t->path = $base->getPath();
if ($r->getQuery()) {
$t->query = $r->getQuery();
} else {
$t->query = $base->getQuery();
}
} else {
if ($r->getPath() && substr($r->getPath(), 0, 1) == "/") {
$t->path = $this->removeDotSegments($r->getPath());
} else {
$t->path = $this->mergePaths($base->getPath(), $r->getPath());
}
$t->query = $r->getQuery();
}
$t->authority = $base->getAuthority();
}
$t->scheme = $base->getScheme();
}
$t->fragment = $r->getFragment();
$result = $this->reconstitute($t->scheme, $t->authority, $t->path, $t->query, $t->fragment);
return new Uri($result);
}
示例7: rewrite
public function rewrite($link)
{
$url = '';
$is_home = false;
$uri = new Uri($link);
if ($uri->getVar('route')) {
$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;
//.........这里部分代码省略.........
示例8: testGetPath
/**
* @covers MediaCore\Uri::getPath
*/
public function testGetPath()
{
$url = 'http://example.com:8080/path/to/directory?foo=bar';
$uri = new Uri($url);
$this->assertEquals('/path/to/directory', $uri->getPath());
}
示例9: testSetPath
public function testSetPath()
{
$uri = new Uri('http', 'www.yahoo.com', '/foo');
$this->assertEquals('/foo', $uri->getPath());
$this->assertEquals('http://www.yahoo.com/foo', $uri->toString());
}
示例10: buildResolvedUriAgainst
private function buildResolvedUriAgainst(Uri $uri)
{
$scheme = $uri->getScheme();
$authority = $uri->getAuthority();
$path = $uri->getPath();
$query = $uri->getQuery();
if ($this->getAuthority()) {
$authority = $this->getAuthority();
$path = $this->getPath();
$query = $this->getQuery();
} elseif ($this->getPath()) {
$path = $this->buildResolvedPathAgainst($uri->getPath());
$query = $this->getQuery();
} elseif ($this->getQuery()) {
$query = $this->getQuery();
}
return $this->appendRelativeParts("{$scheme}://{$authority}{$path}", $query, $this->parts['fragment']);
}