<?php
/**
* @package OpenCart
* @author Daniel Kerr
* @copyright Copyright (c) 2005 - 2017, OpenCart, Ltd. (https://www.opencart.com/)
* @license https://opensource.org/licenses/GPL-3.0
* @author Daniel Kerr
* @see https://www.opencart.com
*/
/**
* URL类
*/
class Url {
// url
private $url;
// 重写
private $rewrite = array();
/**
* Constructor.
* 构造方法
* @param string $url
* @param string $ssl Unused
*/
public function __construct($url, $ssl = '') {
$this->url = $url;
}
/**
*
* 添加重写规则
* @param Controller $rewrite
*
* @return void
*/
public function addRewrite($rewrite) {
$this->rewrite[] = $rewrite;
}
/**
*
* 链接
* @param string $route
* @param string|string[] $args
*
* @return string
*/
public function link($route, $args = '') {
$url = $this->url . 'index.php?route=' . (string)$route;
if ($args) {
if (is_array($args)) {
// 生成请求字符串
$url .= '&' . http_build_query($args, '', '&');
} else {
$url .= str_replace('&', '&', '&' . ltrim($args, '&'));
}
}
foreach ($this->rewrite as $rewrite) {
$url = $rewrite->rewrite($url);
}
return $url;
}
}
【opencart3源码分析】url类url.php
猜你喜欢
转载自blog.csdn.net/qq2942713658/article/details/81415170
今日推荐
周排行