mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-01 15:32:48 +08:00
feat: 视图增加$Controller对象,可以在视图层访问控制器方法;
This commit is contained in:
@@ -124,6 +124,7 @@ class AdminControllerBase extends BaseController
|
||||
$this->viewInit();
|
||||
|
||||
$this->initSort();
|
||||
$this->assign('Controller', $this, -1);
|
||||
}
|
||||
|
||||
public function initSort()
|
||||
|
||||
@@ -82,12 +82,26 @@ class Think
|
||||
return 'app(\'request\')->' . $method . '(' . $params . ')';
|
||||
});
|
||||
|
||||
|
||||
$this->template->extend('$View', function (array $vars) {
|
||||
$params = implode('.', $vars);
|
||||
|
||||
return "'" . Arr::get($this->data, $params, '') . "'";
|
||||
});
|
||||
|
||||
$this->template->extend('$Controller', function (array $vars) {
|
||||
// 获取Request请求对象参数
|
||||
$method = array_shift($vars);
|
||||
if (!empty($vars)) {
|
||||
$params = implode('.', $vars);
|
||||
if ('true' != $params) {
|
||||
$params = '\'' . $params . '\'';
|
||||
}
|
||||
} else {
|
||||
$params = '';
|
||||
}
|
||||
|
||||
return '$Controller->' . $method . '(' . $params . ')';
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user