73 lines
2.2 KiB
PHP
73 lines
2.2 KiB
PHP
<?php
|
|
namespace lib\Core;
|
|
|
|
abstract class Controller
|
|
{
|
|
private $_debug = false;
|
|
private $_models = [];
|
|
protected $view = null;
|
|
protected function __construct()
|
|
{
|
|
$this->view = new View();
|
|
} //
|
|
final public function setDebug($debug)
|
|
{
|
|
$this->_debug = $debug;
|
|
}
|
|
final public function getDebug()
|
|
{
|
|
return $this->_debug;
|
|
}
|
|
|
|
//Model
|
|
final public function getModel($name)
|
|
{
|
|
if (!array_key_exists($name, $this->_models)) {
|
|
//require_once "lib/Model/" . $model . ".php";
|
|
$modelName = sprintf("lib\Model\%s", $name);
|
|
$model = new $modelName();
|
|
if (!$model instanceof Model) {
|
|
throw new \Exception("%s Model이 생성되지 않았습니다\n", $modelName);
|
|
}
|
|
$this->_models[$name] = $model;
|
|
}
|
|
return $this->_models[$name];
|
|
}
|
|
|
|
public function render($file)
|
|
{
|
|
return $this->view->render($file);
|
|
}
|
|
|
|
final public function getSite()
|
|
{
|
|
$domain = array_key_exists("HTTP_HOST", $_SERVER) ? $_SERVER["HTTP_HOST"] : false;
|
|
switch ($domain) {
|
|
case 'dbms.prime-idc.jp':
|
|
return array(
|
|
"id" => "PRIMEIDC",
|
|
"domain" => "ddbms.prime-idc.jp",
|
|
"name" => "PrimeIDC",
|
|
"email" => "support@prime-idc.jp");
|
|
break;
|
|
case "dbms.itsolution-idc.jp":
|
|
return array(
|
|
"id" => "ITSOLUTION",
|
|
"domain" => "dbms.itsolution-idc.jp",
|
|
"name" => "Itsolution",
|
|
"email" => "support@itsoution-idc.jp");
|
|
break;
|
|
case 'dbms.gdidc.jp':
|
|
return array(
|
|
"id" => "GDIDC",
|
|
"domain" => "dbms.gdidc.jp",
|
|
"name" => "GDIDC",
|
|
"email" => "support@gdidc.jp");
|
|
break;
|
|
default:
|
|
throw new \Exception(sprintf(__METHOD__ . "에서 오류 Domain[%s]이 정의되지 않았습니다.", $domain));
|
|
break;
|
|
}
|
|
}
|
|
} //Class
|