mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-02-23 14:59:07 +08:00
move framework files to App/Blessing
This commit is contained in:
parent
875cff557d
commit
98505984e1
21
app/Blessing/Facades/App.php
Normal file
21
app/Blessing/Facades/App.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Blessing\Facades;
|
||||
|
||||
use \Illuminate\Support\Facades\Facade;
|
||||
|
||||
/**
|
||||
* @see \Blessing\Foundation\Application
|
||||
*/
|
||||
class App extends Facade
|
||||
{
|
||||
/**
|
||||
* Get the registered name of the component.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'app';
|
||||
}
|
||||
}
|
18
app/Blessing/Facades/DB.php
Normal file
18
app/Blessing/Facades/DB.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Blessing\Facades;
|
||||
|
||||
use \Illuminate\Support\Facades\Facade;
|
||||
|
||||
class DB extends Facade
|
||||
{
|
||||
/**
|
||||
* Get the registered name of the component.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'db';
|
||||
}
|
||||
}
|
@ -1,9 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
namespace Blessing\Foundation;
|
||||
|
||||
class Application
|
||||
use \Illuminate\Container\Container;
|
||||
use \App\Services\Config;
|
||||
|
||||
class Application extends Container
|
||||
{
|
||||
private $version = null;
|
||||
|
||||
/**
|
||||
* Start Application
|
||||
*
|
||||
@ -17,6 +22,9 @@ class Application
|
||||
// Check Runtime Environment
|
||||
Boot::checkRuntimeEnv();
|
||||
|
||||
// Register Facades
|
||||
Boot::registerFacades($this);
|
||||
|
||||
// Set Default Timezone to UTC+8
|
||||
Boot::setTimeZone();
|
||||
|
||||
@ -40,14 +48,17 @@ class Application
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current app version
|
||||
* Get the version number of the application.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getVersion()
|
||||
public function version()
|
||||
{
|
||||
$config = require BASE_DIR."/config/app.php";
|
||||
return $config['version'];
|
||||
if (is_null($this->version)) {
|
||||
$config = require BASE_DIR."/config/app.php";
|
||||
$this->version = $config['version'];
|
||||
}
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
namespace Blessing\Foundation;
|
||||
|
||||
use \Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use \Illuminate\Support\Facades\Facade;
|
||||
use \Pecee\SimpleRouter\SimpleRouter as Router;
|
||||
use App\Exceptions\ExceptionHandler;
|
||||
use App\Exceptions\E;
|
||||
use \App\Exceptions\ExceptionHandler;
|
||||
use \App\Exceptions\E;
|
||||
use \App\Services\Config;
|
||||
use \App\Services\Http;
|
||||
|
||||
class Boot
|
||||
{
|
||||
@ -17,6 +20,15 @@ class Boot
|
||||
}
|
||||
}
|
||||
|
||||
public static function registerFacades(Application $app)
|
||||
{
|
||||
Facade::setFacadeApplication($app);
|
||||
|
||||
$app->instance('app', $app);
|
||||
$app->bind('manager', \App\Services\PluginManager::class);
|
||||
$app->bind('db', \Blessing\Foundation\Database::class);
|
||||
}
|
||||
|
||||
public static function setTimeZone($timezone = 'Asia/Shanghai')
|
||||
{
|
||||
// set default time zone, UTC+8 for default
|
||||
@ -39,7 +51,7 @@ class Boot
|
||||
throw new E("检测到 `textures` 文件夹已被删除,请重新运行 <a href='./setup'>安装程序</a>,或者手动放置一个。", -1, true);
|
||||
}
|
||||
|
||||
if (Application::getVersion() != Option::get('version', '')) {
|
||||
if (\App::version() != \App\Services\Option::get('version', '')) {
|
||||
Http::redirect(Http::getBaseUrl().'/setup/update.php');
|
||||
exit;
|
||||
}
|
@ -1,35 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
namespace Blessing\Foundation;
|
||||
|
||||
use App\Exceptions\E;
|
||||
|
||||
/**
|
||||
* Facade for DatabaseHelper
|
||||
*/
|
||||
class Database
|
||||
{
|
||||
public function __call($method, $args)
|
||||
{
|
||||
// Instantiate Helper
|
||||
$instance = new DatabaseHelper;
|
||||
// Call methods
|
||||
return call_user_func_array([$instance, $method], $args);
|
||||
}
|
||||
|
||||
public static function __callStatic($method, $args)
|
||||
{
|
||||
$instance = new DatabaseHelper;
|
||||
return call_user_func_array([$instance, $method], $args);
|
||||
}
|
||||
}
|
||||
use \App\Exceptions\E;
|
||||
use \App\Services\Config;
|
||||
|
||||
/**
|
||||
* Light-weight database helper
|
||||
*
|
||||
* @author <h@prinzeugen.net>
|
||||
*/
|
||||
class DatabaseHelper
|
||||
class Database
|
||||
{
|
||||
/**
|
||||
* Instance of MySQLi
|
||||
@ -79,7 +60,7 @@ class DatabaseHelper
|
||||
|
||||
public function table($table_name, $no_prefix = false)
|
||||
{
|
||||
if (Utils::convertString($table_name) == $table_name) {
|
||||
if (mysql_escape_string($table_name) == $table_name) {
|
||||
$this->table_name = $no_prefix ? $table_name : $this->config['prefix'].$table_name;
|
||||
return $this;
|
||||
} else {
|
@ -38,7 +38,7 @@ class AdminController extends BaseController
|
||||
public function update()
|
||||
{
|
||||
if (Utils::getValue('action', $_GET) == "check") {
|
||||
$updater = new \Updater(\App::getVersion());
|
||||
$updater = new \Updater(\App::version());
|
||||
if ($updater->newVersionAvailable()) {
|
||||
View::json([
|
||||
'new_version_available' => true,
|
||||
|
11
app/Services/PluginManager.php
Normal file
11
app/Services/PluginManager.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
class PluginManager
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -14,7 +14,8 @@
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"App\\": "app/"
|
||||
"App\\": "app/",
|
||||
"Blessing\\": "app/Blessing"
|
||||
},
|
||||
"classmap": [
|
||||
"app/Models"
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
return [
|
||||
'View' => 'App\Services\View',
|
||||
'Database' => 'App\Services\Database',
|
||||
'DB' => 'Blessing\Facades\DB',
|
||||
'Option' => 'App\Services\Option',
|
||||
'Utils' => 'App\Services\Utils',
|
||||
'Validate' => 'App\Services\Validate',
|
||||
@ -23,7 +23,7 @@ return [
|
||||
'Updater' => 'App\Services\Updater',
|
||||
'Config' => 'App\Services\Config',
|
||||
'Schema' => 'App\Services\Schema',
|
||||
'Boot' => 'App\Services\Boot',
|
||||
'Boot' => 'Blessing\Foundation\Boot',
|
||||
'Migration' => 'App\Services\Migration',
|
||||
'App' => 'App\Services\Application'
|
||||
'App' => 'Blessing\Facades\App'
|
||||
];
|
||||
|
@ -10,7 +10,7 @@ define('BASE_DIR', __DIR__);
|
||||
require BASE_DIR.'/vendor/autoload.php';
|
||||
|
||||
// Initialize Application
|
||||
$app = new App\Services\Application();
|
||||
$app = new Blessing\Foundation\Application();
|
||||
|
||||
// Start Application
|
||||
$app->run();
|
||||
|
@ -14,7 +14,7 @@
|
||||
</h1>
|
||||
</section>
|
||||
|
||||
<?php $updater = new Updater(App::getVersion()); ?>
|
||||
<?php $updater = new Updater(App::version()); ?>
|
||||
<!-- Main content -->
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
|
@ -10,7 +10,7 @@ define('BASE_DIR', dirname(dirname(__FILE__)));
|
||||
require BASE_DIR.'/vendor/autoload.php';
|
||||
|
||||
// Boot Services
|
||||
App\Services\Boot::loadServices();
|
||||
Blessing\Foundation\Boot::loadServices();
|
||||
Config::checkPHPVersion();
|
||||
Boot::loadDotEnv(BASE_DIR);
|
||||
Boot::registerErrorHandler(new \Whoops\Handler\PrettyPageHandler);
|
||||
|
@ -10,7 +10,7 @@ define('BASE_DIR', dirname(dirname(dirname(__FILE__))));
|
||||
require BASE_DIR.'/vendor/autoload.php';
|
||||
|
||||
// Boot Services
|
||||
App\Services\Boot::loadServices();
|
||||
Blessing\Foundation\Boot::loadServices();
|
||||
Config::checkPHPVersion();
|
||||
Boot::loadDotEnv(BASE_DIR);
|
||||
Boot::registerErrorHandler(new \Whoops\Handler\PrettyPageHandler);
|
||||
|
@ -10,7 +10,7 @@ define('BASE_DIR', dirname(dirname(__FILE__)));
|
||||
require BASE_DIR.'/vendor/autoload.php';
|
||||
|
||||
// Boot Services
|
||||
App\Services\Boot::loadServices();
|
||||
Blessing\Foundation\Boot::loadServices();
|
||||
Config::checkPHPVersion();
|
||||
Boot::loadDotEnv(BASE_DIR);
|
||||
Boot::registerErrorHandler(new \Whoops\Handler\PrettyPageHandler);
|
||||
|
Loading…
Reference in New Issue
Block a user