mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-06 07:02:47 +08:00
取消 CONTROLLER_LAYER MODEL_LAYER VIEW_LAYER VALIDATE_LAYER 常量 增加url_controller_layer 配置参数
This commit is contained in:
@@ -246,7 +246,7 @@ class App
|
||||
// 模块初始化
|
||||
if (MODULE_NAME && $available) {
|
||||
define('MODULE_PATH', APP_PATH . MODULE_NAME . DS);
|
||||
define('VIEW_PATH', MODULE_PATH . VIEW_LAYER . DS);
|
||||
define('VIEW_PATH', MODULE_PATH . 'view' . DS);
|
||||
// 初始化模块
|
||||
$config = self::initModule(MODULE_NAME, $config);
|
||||
} else {
|
||||
@@ -256,7 +256,7 @@ class App
|
||||
// 单一模块部署
|
||||
define('MODULE_NAME', '');
|
||||
define('MODULE_PATH', APP_PATH);
|
||||
define('VIEW_PATH', MODULE_PATH . VIEW_LAYER . DS);
|
||||
define('VIEW_PATH', MODULE_PATH . 'view' . DS);
|
||||
}
|
||||
|
||||
// 获取控制器名
|
||||
@@ -272,7 +272,7 @@ class App
|
||||
// 安全检测
|
||||
throw new Exception('illegal controller name:' . CONTROLLER_NAME, 10000);
|
||||
}
|
||||
$instance = Loader::controller(CONTROLLER_NAME, '', $config['use_controller_suffix'], $config['empty_controller']);
|
||||
$instance = Loader::controller(CONTROLLER_NAME, $config['url_controller_layer'], $config['use_controller_suffix'], $config['empty_controller']);
|
||||
// 获取当前操作名
|
||||
$action = ACTION_NAME . $config['action_suffix'];
|
||||
|
||||
|
||||
@@ -132,13 +132,13 @@ class Build
|
||||
$namespace = APP_NAMESPACE . '\\' . ($module ? $module . '\\' : '') . $path;
|
||||
$class = $val . (CLASS_APPEND_SUFFIX ? ucfirst($path) : '');
|
||||
switch ($path) {
|
||||
case CONTROLLER_LAYER: // 控制器
|
||||
case 'controller': // 控制器
|
||||
$content = "<?php\nnamespace {$namespace};\n\nclass {$class}\n{\n\n}";
|
||||
break;
|
||||
case MODEL_LAYER: // 模型
|
||||
case 'model': // 模型
|
||||
$content = "<?php\nnamespace {$namespace};\n\nuse think\Model;\n\nclass {$class} extends Model\n{\n\n}";
|
||||
break;
|
||||
case VIEW_LAYER: // 视图
|
||||
case 'view': // 视图
|
||||
$filename = $modulePath . $path . DS . $val . '.html';
|
||||
if (!is_dir(dirname($filename))) {
|
||||
// 创建目录
|
||||
@@ -167,10 +167,10 @@ class Build
|
||||
*/
|
||||
protected static function buildHello($module)
|
||||
{
|
||||
$filename = APP_PATH . ($module ? $module . DS : '') . CONTROLLER_LAYER . DS . 'Index' . (CLASS_APPEND_SUFFIX ? ucfirst(CONTROLLER_LAYER) : '') . EXT;
|
||||
$filename = APP_PATH . ($module ? $module . DS : '') . 'controller' . DS . 'Index' . (CLASS_APPEND_SUFFIX ? 'Controller' : '') . EXT;
|
||||
if (!is_file($filename)) {
|
||||
$content = file_get_contents(THINK_PATH . 'tpl' . DS . 'default_index.tpl');
|
||||
$content = str_replace(['{$app}', '{$module}', '{layer}', '{$suffix}'], [APP_NAMESPACE, $module ? $module . '\\' : '', CONTROLLER_LAYER, CLASS_APPEND_SUFFIX ? ucfirst(CONTROLLER_LAYER) : ''], $content);
|
||||
$content = str_replace(['{$app}', '{$module}', '{layer}', '{$suffix}'], [APP_NAMESPACE, $module ? $module . '\\' : '', 'controller', CLASS_APPEND_SUFFIX ? 'Controller' : ''], $content);
|
||||
if (!is_dir(dirname($filename))) {
|
||||
mkdir(dirname($filename), 0777, true);
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ class Loader
|
||||
* @param bool $appendSuffix 是否添加类名后缀
|
||||
* @return Object
|
||||
*/
|
||||
public static function model($name = '', $layer = MODEL_LAYER, $appendSuffix = false)
|
||||
public static function model($name = '', $layer = 'model', $appendSuffix = false)
|
||||
{
|
||||
static $_model = [];
|
||||
if (isset($_model[$name . $layer])) {
|
||||
@@ -301,10 +301,10 @@ class Loader
|
||||
* @param string $empty 空控制器名称
|
||||
* @return Object|false
|
||||
*/
|
||||
public static function controller($name, $layer = '', $appendSuffix = false, $empty = '')
|
||||
public static function controller($name, $layer = 'controller', $appendSuffix = false, $empty = '')
|
||||
{
|
||||
static $_instance = [];
|
||||
$layer = $layer ?: CONTROLLER_LAYER;
|
||||
|
||||
if (isset($_instance[$name . $layer])) {
|
||||
return $_instance[$name . $layer];
|
||||
}
|
||||
@@ -332,14 +332,14 @@ class Loader
|
||||
* @param bool $appendSuffix 是否添加类名后缀
|
||||
* @return Object|false
|
||||
*/
|
||||
public static function validate($name = '', $layer = '', $appendSuffix = false)
|
||||
public static function validate($name = '', $layer = 'validate', $appendSuffix = false)
|
||||
{
|
||||
$name = $name ?: Config::get('default_validate');
|
||||
if (empty($name)) {
|
||||
return new Validate;
|
||||
}
|
||||
static $_instance = [];
|
||||
$layer = $layer ?: VALIDATE_LAYER;
|
||||
|
||||
if (isset($_instance[$name . $layer])) {
|
||||
return $_instance[$name . $layer];
|
||||
}
|
||||
@@ -381,7 +381,7 @@ class Loader
|
||||
* @param bool $appendSuffix 是否添加类名后缀
|
||||
* @return mixed
|
||||
*/
|
||||
public static function action($url, $vars = [], $layer = CONTROLLER_LAYER, $appendSuffix = false)
|
||||
public static function action($url, $vars = [], $layer = 'controller', $appendSuffix = false)
|
||||
{
|
||||
$info = pathinfo($url);
|
||||
$action = $info['basename'];
|
||||
|
||||
@@ -883,8 +883,8 @@ class Route
|
||||
$module = APP_MULTI_MODULE ? array_shift($path) : null;
|
||||
if ($autoSearch) {
|
||||
// 自动搜索控制器
|
||||
$dir = APP_PATH . ($module ? $module . DS : '') . CONTROLLER_LAYER;
|
||||
$suffix = CLASS_APPEND_SUFFIX || Config::get('use_controller_suffix') ? ucfirst(CONTROLLER_LAYER) : '';
|
||||
$dir = APP_PATH . ($module ? $module . DS : '') . 'controller';
|
||||
$suffix = CLASS_APPEND_SUFFIX || Config::get('use_controller_suffix') ? 'Controller' : '';
|
||||
$item = [];
|
||||
foreach ($path as $val) {
|
||||
$item[] = array_shift($path);
|
||||
|
||||
@@ -335,7 +335,11 @@ abstract class Builder
|
||||
$whereStr .= $key . ' ' . $exp . ' ' . $this->parseValue($data[0]) . ' AND ' . $this->parseValue($data[1]);
|
||||
} elseif (in_array($exp, ['NOT EXISTS', 'EXISTS'])) {
|
||||
// EXISTS 查询
|
||||
$whereStr .= $exp . ' ' . $this->parseClosure($value);
|
||||
if ($value instanceof \Closure) {
|
||||
$whereStr .= $exp . ' ' . $this->parseClosure($value);
|
||||
} else {
|
||||
$whereStr .= $exp . ' (' . $value . ')';
|
||||
}
|
||||
}
|
||||
return $whereStr;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ class Php
|
||||
|
||||
if (strpos($template, '@')) {
|
||||
list($module, $template) = explode('@', $template);
|
||||
$path = APP_PATH . $module . DS . VIEW_LAYER . DS;
|
||||
$path = APP_PATH . $module . DS . 'view' . DS;
|
||||
} else {
|
||||
$path = $this->config['view_path'];
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ class Think
|
||||
if (strpos($template, '@')) {
|
||||
// 跨模块调用
|
||||
list($module, $template) = explode('@', $template);
|
||||
$path = APP_PATH . $module . DS . VIEW_LAYER . DS;
|
||||
$path = APP_PATH . $module . DS . 'view' . DS;
|
||||
} else {
|
||||
// 当前视图目录
|
||||
$path = $this->config['view_path'];
|
||||
|
||||
Reference in New Issue
Block a user