util 클래스 변경
게임 내부 파일에 대해서 autoloader 적용
This commit is contained in:
+22
-19
@@ -3,6 +3,28 @@ namespace sammo;
|
||||
|
||||
require(__dir__.'/../vendor/autoload.php');
|
||||
|
||||
/**
|
||||
* https://php.net/manual/kr/language.oop5.autoload.php#120258
|
||||
* 현재 디렉토리 기준으로 php 파일 탐색.
|
||||
*/
|
||||
class Autoloader
|
||||
{
|
||||
public static function register()
|
||||
{
|
||||
spl_autoload_register(function ($class) {
|
||||
if(util::starts_with($class, 'sammo\\')){
|
||||
$class = substr($class, strlen('sammo\\'));
|
||||
}
|
||||
$file = __DIR__.DIRECTORY_SEPARATOR.str_replace('\\', DIRECTORY_SEPARATOR, $class).'.php';
|
||||
if (file_exists($file)) {
|
||||
require $file;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
Autoloader::register();
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
@@ -143,25 +165,6 @@ function SetHeaderNoCache(){
|
||||
}
|
||||
}
|
||||
|
||||
function Json::die($value, $noCache = true, $pretty = false, $die = true){
|
||||
if($noCache){
|
||||
SetHeaderNoCache();
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
if($pretty){
|
||||
$flag = JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT;
|
||||
}
|
||||
else{
|
||||
$flag = JSON_UNESCAPED_UNICODE;
|
||||
}
|
||||
echo json_encode($value, $flag);
|
||||
if($die){
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
// 게시판의 생성유무 검사
|
||||
function isTable($connect, $str, $dbname='') {
|
||||
if(!$dbname) {
|
||||
|
||||
Reference in New Issue
Block a user