diff --git a/framework/create/tpl/config/config.tpl b/framework/create/tpl/config/config.tpl index 8a179b2..e8ac786 100644 --- a/framework/create/tpl/config/config.tpl +++ b/framework/create/tpl/config/config.tpl @@ -1,9 +1,9 @@ [ - 'Top' => 'system.library.template.Top', - // 'Smarty' => 'system.library.template.Smarty' - // 'Twig' => 'system.library.template.Twig', + 'Twig' => top\library\template\Twig::class, + // 'Smarty' => top\library\template\Smarty::class, + // 'Top' => top\library\template\Top::class, ], 'decorator' => [], 'session' => [ @@ -19,11 +19,11 @@ return [ 'charset' => 'utf8' ], 'view' => [ - 'engine' => 'Top', + 'engine' => 'Twig', 'ext' => 'html', - 'dir' => '../{namespace}/{name}/view/', - 'cacheDir' => './runtime/cache/{namespace}/{name}/', - 'compileDir' => './runtime/compile/{namespace}/{name}/', + 'dir' => '../application/{name}/view/', + 'cacheDir' => './runtime/cache/application/{name}/', + 'compileDir' => './runtime/compile/application/{name}/', 'left' => '{', 'right' => '}', 'cacheTime' => 5 diff --git a/framework/create/tpl/controller/index.tpl b/framework/create/tpl/controller/index.tpl index 7c0e4cd..acc8bf2 100644 --- a/framework/create/tpl/controller/index.tpl +++ b/framework/create/tpl/controller/index.tpl @@ -1,8 +1,8 @@ get('register'); diff --git a/framework/library/Controller.php b/framework/library/Controller.php index c364fd6..b4d2a5f 100644 --- a/framework/library/Controller.php +++ b/framework/library/Controller.php @@ -19,7 +19,7 @@ abstract class Controller { * @param array $ext * @return false|string */ - public function json($msg, $code = 1, $data = [], $ext = []) { + protected function json($msg, $code = 1, $data = [], $ext = []) { $array = [ 'msg' => $msg, 'code' => $code, @@ -34,7 +34,7 @@ abstract class Controller { * @param bool $status * @return $this */ - public function cache($status = true) { + protected function cache($status = true) { Register::get('View')->cache($status); return $this; } @@ -44,7 +44,7 @@ abstract class Controller { * @param $name * @param $value */ - public function param($name, $value) { + protected function param($name, $value) { Register::get('View')->param($name, $value); } @@ -55,7 +55,7 @@ abstract class Controller { * @param bool $cache * @return mixed */ - public function fetch($file = '', $param = [], $cache = false) { + protected function fetch($file = '', $param = [], $cache = false) { return Register::get('View')->fetch($file, $param, $cache); } @@ -63,7 +63,7 @@ abstract class Controller { * 跳转(非ajax) * @param $url */ - public function redirect($url) { + protected function redirect($url) { return redirect($url); } @@ -74,7 +74,7 @@ abstract class Controller { * @param int $sec * @return false|mixed|string */ - public function tips($message, $url = '', $sec = 3) { + protected function tips($message, $url = '', $sec = 3) { if (request()->isAjax()) { return $this->json($message, '', 'tips', ['url' => $url, 'sec' => $sec]); } else { diff --git a/framework/library/Loader.php b/framework/library/Loader.php index 60a493a..56a89f7 100644 --- a/framework/library/Loader.php +++ b/framework/library/Loader.php @@ -4,7 +4,7 @@ namespace top\library; class Loader { - protected $prefixes = []; + private $prefixes = []; public function register() { spl_autoload_register([$this, 'loadClass']); @@ -18,7 +18,7 @@ class Loader { } } - protected function loadClass($class) { + private function loadClass($class) { // 首次,将前缀等于当前类名 $prefix = $class; // 从最后一个反斜杠开始分割前缀与类名 @@ -38,7 +38,7 @@ class Loader { return false; } - protected function loadFile($prefix, $class) { + private function loadFile($prefix, $class) { // echo $class . '
'; $prefix = trim($prefix, '\\'); // 如果存在此前缀 diff --git a/framework/library/Model.php b/framework/library/Model.php index b78e586..00bb562 100644 --- a/framework/library/Model.php +++ b/framework/library/Model.php @@ -365,7 +365,7 @@ abstract class Model { * @param array $data * @return array */ - public function inHandle($data) { + private function inHandle($data) { $replace = ($this->isInsert) ? $this->insertHandle : $this->updateHandle; foreach ($replace as $key => $value) { $fieldValue = ''; diff --git a/framework/library/Router.php b/framework/library/Router.php index 2240f9c..82446fb 100644 --- a/framework/library/Router.php +++ b/framework/library/Router.php @@ -17,14 +17,14 @@ use top\library\route\ifs\RouteIfs; class Router { // 路由实例 - public $route; + private $route; // 装饰器 - public $decorator = []; + private $decorator = []; public $module = ''; - public $className = ''; + public $class = ''; public $ctrl = ''; @@ -64,14 +64,14 @@ class Router { * 指定装饰器 * @param DecoratorIfs $decorator */ - public function decorator(DecoratorIfs $decorator) { + private function decorator(DecoratorIfs $decorator) { $this->decorator[] = $decorator; } /** * 装饰器前置方法 */ - public function beforeRoute() { + private function beforeRoute() { foreach ($this->decorator as $decorator) { $decorator->before(); } @@ -81,7 +81,7 @@ class Router { * 装饰器后置方法 * @param $data */ - public function afterRoute($data) { + private function afterRoute($data) { $this->decorator = array_reverse($this->decorator); foreach ($this->decorator as $decorator) { $decorator->after($data); @@ -92,7 +92,7 @@ class Router { * 执行前进行必要检查 * @throws RouteException */ - public function check() { + private function check() { // 检查模块是否存在 if (!is_dir(APP_PATH . $this->module)) { throw new RouteException('模块' . $this->module . '不存在'); diff --git a/framework/library/cache/FileCache.php b/framework/library/cache/File.php similarity index 95% rename from framework/library/cache/FileCache.php rename to framework/library/cache/File.php index 12c3f08..30e5a56 100644 --- a/framework/library/cache/FileCache.php +++ b/framework/library/cache/File.php @@ -3,12 +3,10 @@ namespace top\library\cache; use top\library\cache\ifs\CacheIfs; -class FileCache implements CacheIfs { +class File implements CacheIfs { private static $instance; - private $cacheDir = ''; - public static function instance() { if (! self::$instance) { self::$instance = new self(); @@ -18,6 +16,9 @@ class FileCache implements CacheIfs { private function __construct() {} + private function __clone() { + } + /** * * {@inheritdoc} diff --git a/framework/library/database/driver/MySQLi.php b/framework/library/database/driver/MySQLi.php index 18c4e8c..0b3e32a 100644 --- a/framework/library/database/driver/MySQLi.php +++ b/framework/library/database/driver/MySQLi.php @@ -386,7 +386,7 @@ class MySQLi implements DatabaseIfs { * @param string|array $on * @return string */ - public function processJoin($data, $on) { + private function processJoin($data, $on) { $join = []; for ($i = 0; $i < count($data); $i++) { if (is_array($on[$i])) { @@ -431,7 +431,7 @@ class MySQLi implements DatabaseIfs { return $value; } - public function writeLogs($result, $query) { + private function writeLogs($result, $query) { if (DEBUG) { $error = ''; if (!$result) { diff --git a/framework/library/template/tags/Tags.php b/framework/library/template/tags/Tags.php index d82c283..de10114 100644 --- a/framework/library/template/tags/Tags.php +++ b/framework/library/template/tags/Tags.php @@ -117,7 +117,7 @@ class Tags { * @param string $filename * @return string */ - public function processingViewTag($filename) { + private function processingViewTag($filename) { $tags = [ 'view:name' => '$___view__config = \\framework\\library\\Register::get(\'Config\')->get(\'view\'); require BASEDIR . \'/\' . $___view__config[\'dir\'] . \'name\' . \'.\' . $___view__config[\'ext\'];' ];