修改部分访问修饰符
This commit is contained in:
parent
94f6b1cb95
commit
2e7f047c76
|
@ -1,9 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
return [
|
return [
|
||||||
'register' => [
|
'register' => [
|
||||||
'Top' => 'system.library.template.Top',
|
'Twig' => top\library\template\Twig::class,
|
||||||
// 'Smarty' => 'system.library.template.Smarty'
|
// 'Smarty' => top\library\template\Smarty::class,
|
||||||
// 'Twig' => 'system.library.template.Twig',
|
// 'Top' => top\library\template\Top::class,
|
||||||
],
|
],
|
||||||
'decorator' => [],
|
'decorator' => [],
|
||||||
'session' => [
|
'session' => [
|
||||||
|
@ -19,11 +19,11 @@ return [
|
||||||
'charset' => 'utf8'
|
'charset' => 'utf8'
|
||||||
],
|
],
|
||||||
'view' => [
|
'view' => [
|
||||||
'engine' => 'Top',
|
'engine' => 'Twig',
|
||||||
'ext' => 'html',
|
'ext' => 'html',
|
||||||
'dir' => '../{namespace}/{name}/view/',
|
'dir' => '../application/{name}/view/',
|
||||||
'cacheDir' => './runtime/cache/{namespace}/{name}/',
|
'cacheDir' => './runtime/cache/application/{name}/',
|
||||||
'compileDir' => './runtime/compile/{namespace}/{name}/',
|
'compileDir' => './runtime/compile/application/{name}/',
|
||||||
'left' => '{',
|
'left' => '{',
|
||||||
'right' => '}',
|
'right' => '}',
|
||||||
'cacheTime' => 5
|
'cacheTime' => 5
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
namespace {namespace}\{name}\controller;
|
namespace app\{name}\controller;
|
||||||
|
|
||||||
use system\top\Controller;
|
use top\library\Controller;
|
||||||
use {namespace}\{name}\model\Demo;
|
use app\{name}\model\Demo;
|
||||||
|
|
||||||
class Index extends Controller {
|
class Index extends Controller {
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use \top\Framework;
|
||||||
|
|
||||||
// 是否开启DEBUG模式
|
// 是否开启DEBUG模式
|
||||||
define('DEBUG', true);
|
define('DEBUG', true);
|
||||||
// 根目录
|
// APP目录
|
||||||
define('BASEDIR', __DIR__ );
|
define('APP_PATH', '../application/');
|
||||||
// APP的根命名空间
|
// 框架目录
|
||||||
define('APPNAMESPACE', '{namespace}');
|
define('FRAMEWORK_PATH', '../framework/');
|
||||||
// 加载框架
|
// 加载框架
|
||||||
require BASEDIR . '/system/Top.php';
|
require '../framework/Framework.php';
|
||||||
\system\Top::entry();
|
|
||||||
|
Framework::startApp();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace {namespace}\{name}\model;
|
namespace app\{name}\model;
|
||||||
|
|
||||||
use system\top\Model;
|
use top\library\Model;
|
||||||
|
|
||||||
class Demo extends Model {
|
class Demo extends Model {
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{$data}
|
{{ data }}
|
|
@ -35,9 +35,9 @@ class InitDecorator implements DecoratorIfs {
|
||||||
});
|
});
|
||||||
|
|
||||||
// 视图文件缓存
|
// 视图文件缓存
|
||||||
Register::set('ViewCache', function () {
|
/*Register::set('ViewCache', function () {
|
||||||
return FileCache::instance();
|
return FileCache::instance();
|
||||||
});
|
});*/
|
||||||
|
|
||||||
// 配置文件中配置的注册
|
// 配置文件中配置的注册
|
||||||
$initRegister = Register::get('Config')->get('register');
|
$initRegister = Register::get('Config')->get('register');
|
||||||
|
|
|
@ -19,7 +19,7 @@ abstract class Controller {
|
||||||
* @param array $ext
|
* @param array $ext
|
||||||
* @return false|string
|
* @return false|string
|
||||||
*/
|
*/
|
||||||
public function json($msg, $code = 1, $data = [], $ext = []) {
|
protected function json($msg, $code = 1, $data = [], $ext = []) {
|
||||||
$array = [
|
$array = [
|
||||||
'msg' => $msg,
|
'msg' => $msg,
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
|
@ -34,7 +34,7 @@ abstract class Controller {
|
||||||
* @param bool $status
|
* @param bool $status
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function cache($status = true) {
|
protected function cache($status = true) {
|
||||||
Register::get('View')->cache($status);
|
Register::get('View')->cache($status);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ abstract class Controller {
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param $value
|
* @param $value
|
||||||
*/
|
*/
|
||||||
public function param($name, $value) {
|
protected function param($name, $value) {
|
||||||
Register::get('View')->param($name, $value);
|
Register::get('View')->param($name, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ abstract class Controller {
|
||||||
* @param bool $cache
|
* @param bool $cache
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function fetch($file = '', $param = [], $cache = false) {
|
protected function fetch($file = '', $param = [], $cache = false) {
|
||||||
return Register::get('View')->fetch($file, $param, $cache);
|
return Register::get('View')->fetch($file, $param, $cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ abstract class Controller {
|
||||||
* 跳转(非ajax)
|
* 跳转(非ajax)
|
||||||
* @param $url
|
* @param $url
|
||||||
*/
|
*/
|
||||||
public function redirect($url) {
|
protected function redirect($url) {
|
||||||
return redirect($url);
|
return redirect($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ abstract class Controller {
|
||||||
* @param int $sec
|
* @param int $sec
|
||||||
* @return false|mixed|string
|
* @return false|mixed|string
|
||||||
*/
|
*/
|
||||||
public function tips($message, $url = '', $sec = 3) {
|
protected function tips($message, $url = '', $sec = 3) {
|
||||||
if (request()->isAjax()) {
|
if (request()->isAjax()) {
|
||||||
return $this->json($message, '', 'tips', ['url' => $url, 'sec' => $sec]);
|
return $this->json($message, '', 'tips', ['url' => $url, 'sec' => $sec]);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace top\library;
|
||||||
|
|
||||||
class Loader {
|
class Loader {
|
||||||
|
|
||||||
protected $prefixes = [];
|
private $prefixes = [];
|
||||||
|
|
||||||
public function register() {
|
public function register() {
|
||||||
spl_autoload_register([$this, 'loadClass']);
|
spl_autoload_register([$this, 'loadClass']);
|
||||||
|
@ -18,7 +18,7 @@ class Loader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function loadClass($class) {
|
private function loadClass($class) {
|
||||||
// 首次,将前缀等于当前类名
|
// 首次,将前缀等于当前类名
|
||||||
$prefix = $class;
|
$prefix = $class;
|
||||||
// 从最后一个反斜杠开始分割前缀与类名
|
// 从最后一个反斜杠开始分割前缀与类名
|
||||||
|
@ -38,7 +38,7 @@ class Loader {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function loadFile($prefix, $class) {
|
private function loadFile($prefix, $class) {
|
||||||
// echo $class . '<br>';
|
// echo $class . '<br>';
|
||||||
$prefix = trim($prefix, '\\');
|
$prefix = trim($prefix, '\\');
|
||||||
// 如果存在此前缀
|
// 如果存在此前缀
|
||||||
|
|
|
@ -365,7 +365,7 @@ abstract class Model {
|
||||||
* @param array $data
|
* @param array $data
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function inHandle($data) {
|
private function inHandle($data) {
|
||||||
$replace = ($this->isInsert) ? $this->insertHandle : $this->updateHandle;
|
$replace = ($this->isInsert) ? $this->insertHandle : $this->updateHandle;
|
||||||
foreach ($replace as $key => $value) {
|
foreach ($replace as $key => $value) {
|
||||||
$fieldValue = '';
|
$fieldValue = '';
|
||||||
|
|
|
@ -17,14 +17,14 @@ use top\library\route\ifs\RouteIfs;
|
||||||
class Router {
|
class Router {
|
||||||
|
|
||||||
// 路由实例
|
// 路由实例
|
||||||
public $route;
|
private $route;
|
||||||
|
|
||||||
// 装饰器
|
// 装饰器
|
||||||
public $decorator = [];
|
private $decorator = [];
|
||||||
|
|
||||||
public $module = '';
|
public $module = '';
|
||||||
|
|
||||||
public $className = '';
|
public $class = '';
|
||||||
|
|
||||||
public $ctrl = '';
|
public $ctrl = '';
|
||||||
|
|
||||||
|
@ -64,14 +64,14 @@ class Router {
|
||||||
* 指定装饰器
|
* 指定装饰器
|
||||||
* @param DecoratorIfs $decorator
|
* @param DecoratorIfs $decorator
|
||||||
*/
|
*/
|
||||||
public function decorator(DecoratorIfs $decorator) {
|
private function decorator(DecoratorIfs $decorator) {
|
||||||
$this->decorator[] = $decorator;
|
$this->decorator[] = $decorator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 装饰器前置方法
|
* 装饰器前置方法
|
||||||
*/
|
*/
|
||||||
public function beforeRoute() {
|
private function beforeRoute() {
|
||||||
foreach ($this->decorator as $decorator) {
|
foreach ($this->decorator as $decorator) {
|
||||||
$decorator->before();
|
$decorator->before();
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ class Router {
|
||||||
* 装饰器后置方法
|
* 装饰器后置方法
|
||||||
* @param $data
|
* @param $data
|
||||||
*/
|
*/
|
||||||
public function afterRoute($data) {
|
private function afterRoute($data) {
|
||||||
$this->decorator = array_reverse($this->decorator);
|
$this->decorator = array_reverse($this->decorator);
|
||||||
foreach ($this->decorator as $decorator) {
|
foreach ($this->decorator as $decorator) {
|
||||||
$decorator->after($data);
|
$decorator->after($data);
|
||||||
|
@ -92,7 +92,7 @@ class Router {
|
||||||
* 执行前进行必要检查
|
* 执行前进行必要检查
|
||||||
* @throws RouteException
|
* @throws RouteException
|
||||||
*/
|
*/
|
||||||
public function check() {
|
private function check() {
|
||||||
// 检查模块是否存在
|
// 检查模块是否存在
|
||||||
if (!is_dir(APP_PATH . $this->module)) {
|
if (!is_dir(APP_PATH . $this->module)) {
|
||||||
throw new RouteException('模块' . $this->module . '不存在');
|
throw new RouteException('模块' . $this->module . '不存在');
|
||||||
|
|
|
@ -3,12 +3,10 @@ namespace top\library\cache;
|
||||||
|
|
||||||
use top\library\cache\ifs\CacheIfs;
|
use top\library\cache\ifs\CacheIfs;
|
||||||
|
|
||||||
class FileCache implements CacheIfs {
|
class File implements CacheIfs {
|
||||||
|
|
||||||
private static $instance;
|
private static $instance;
|
||||||
|
|
||||||
private $cacheDir = '';
|
|
||||||
|
|
||||||
public static function instance() {
|
public static function instance() {
|
||||||
if (! self::$instance) {
|
if (! self::$instance) {
|
||||||
self::$instance = new self();
|
self::$instance = new self();
|
||||||
|
@ -18,6 +16,9 @@ class FileCache implements CacheIfs {
|
||||||
|
|
||||||
private function __construct() {}
|
private function __construct() {}
|
||||||
|
|
||||||
|
private function __clone() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
|
@ -386,7 +386,7 @@ class MySQLi implements DatabaseIfs {
|
||||||
* @param string|array $on
|
* @param string|array $on
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function processJoin($data, $on) {
|
private function processJoin($data, $on) {
|
||||||
$join = [];
|
$join = [];
|
||||||
for ($i = 0; $i < count($data); $i++) {
|
for ($i = 0; $i < count($data); $i++) {
|
||||||
if (is_array($on[$i])) {
|
if (is_array($on[$i])) {
|
||||||
|
@ -431,7 +431,7 @@ class MySQLi implements DatabaseIfs {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function writeLogs($result, $query) {
|
private function writeLogs($result, $query) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
$error = '';
|
$error = '';
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
|
|
|
@ -117,7 +117,7 @@ class Tags {
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function processingViewTag($filename) {
|
private function processingViewTag($filename) {
|
||||||
$tags = [
|
$tags = [
|
||||||
'view:name' => '$___view__config = \\framework\\library\\Register::get(\'Config\')->get(\'view\'); require BASEDIR . \'/\' . $___view__config[\'dir\'] . \'name\' . \'.\' . $___view__config[\'ext\'];'
|
'view:name' => '$___view__config = \\framework\\library\\Register::get(\'Config\')->get(\'view\'); require BASEDIR . \'/\' . $___view__config[\'dir\'] . \'name\' . \'.\' . $___view__config[\'ext\'];'
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in New Issue