beautify, gestion charset mysql
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<ruleset>
|
<ruleset>
|
||||||
<rule ref="PSR12"/>
|
<rule ref="PSR12"/>
|
||||||
<file>src/</file>
|
<file>src/</file>
|
||||||
<file>console</file>
|
|
||||||
<arg name="colors"/>
|
<arg name="colors"/>
|
||||||
</ruleset>
|
</ruleset>
|
||||||
@@ -8,7 +8,7 @@ use DateTimeZone;
|
|||||||
class Home extends Controller
|
class Home extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$date = new \DateTime('now', new DateTimeZone("Europe/Paris"));
|
$date = new \DateTime('now', new DateTimeZone("Europe/Paris"));
|
||||||
$html = $this->renderView("index", ["date" => $date->format("d/m/Y H:i:s")]);
|
$html = $this->renderView("index", ["date" => $date->format("d/m/Y H:i:s")]);
|
||||||
$this->render($html);
|
$this->render($html);
|
||||||
|
|||||||
@@ -5,16 +5,16 @@ namespace Kletellier\Framework\Core\Kernel;
|
|||||||
use Kletellier\Framework\Core\Routing\Router;
|
use Kletellier\Framework\Core\Routing\Router;
|
||||||
use Kletellier\Framework\Core\Kernel\Container;
|
use Kletellier\Framework\Core\Kernel\Container;
|
||||||
use Dotenv\Dotenv;
|
use Dotenv\Dotenv;
|
||||||
use Kletellier\PdoWrapper\Connection;
|
use Kletellier\PdoWrapper\Connection;
|
||||||
|
|
||||||
class Application
|
class Application
|
||||||
{
|
{
|
||||||
protected Router $router;
|
protected Router $router;
|
||||||
protected $_whoops;
|
protected $_whoops;
|
||||||
private $_root;
|
private $_root;
|
||||||
|
|
||||||
public function __construct(string $root)
|
public function __construct(string $root)
|
||||||
{
|
{
|
||||||
$this->_root = $root;
|
$this->_root = $root;
|
||||||
|
|
||||||
// enable error reporting
|
// enable error reporting
|
||||||
@@ -36,7 +36,7 @@ class Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create container
|
// create container
|
||||||
Container::set("ROOT",$this->_root);
|
Container::set("ROOT", $this->_root);
|
||||||
|
|
||||||
$db_config = $this->getDatabaseConfig();
|
$db_config = $this->getDatabaseConfig();
|
||||||
|
|
||||||
@@ -77,6 +77,12 @@ class Application
|
|||||||
$conn["DATABASE"] = $this->_root . DIRECTORY_SEPARATOR . "databases" . DIRECTORY_SEPARATOR . $conn["DATABASE"];
|
$conn["DATABASE"] = $this->_root . DIRECTORY_SEPARATOR . "databases" . DIRECTORY_SEPARATOR . $conn["DATABASE"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($conn["TYPE"] == "mysql") {
|
||||||
|
$charset = isset($_ENV[$this->getKey("CHARSET", $key)]) ? $_ENV[$this->getKey("CHARSET", $key)] : null;
|
||||||
|
if ($charset !== null) {
|
||||||
|
$conn["CHARSET"] = $charset;
|
||||||
|
}
|
||||||
|
}
|
||||||
$ret[$connection] = $conn;
|
$ret[$connection] = $conn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,18 @@
|
|||||||
|
|
||||||
namespace Kletellier\Framework\Core\Kernel;
|
namespace Kletellier\Framework\Core\Kernel;
|
||||||
|
|
||||||
class Container
|
class Container
|
||||||
{
|
{
|
||||||
private static $instance;
|
private static $instance;
|
||||||
private array $container;
|
private array $container;
|
||||||
|
|
||||||
private function __construct() {
|
private function __construct()
|
||||||
|
{
|
||||||
$this->container = [];
|
$this->container = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getInstance() {
|
public static function getInstance()
|
||||||
|
{
|
||||||
if (self::$instance === null) {
|
if (self::$instance === null) {
|
||||||
self::$instance = new self();
|
self::$instance = new self();
|
||||||
}
|
}
|
||||||
@@ -19,23 +21,25 @@ class Container
|
|||||||
return self::$instance;
|
return self::$instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setValue($key, $value) {
|
public function setValue($key, $value)
|
||||||
|
{
|
||||||
$this->container[$key] = $value;
|
$this->container[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getValue($key) {
|
public function getValue($key)
|
||||||
|
{
|
||||||
return isset($this->container[$key]) ? $this->container[$key] : null;
|
return isset($this->container[$key]) ? $this->container[$key] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get(string $key)
|
public static function get(string $key)
|
||||||
{
|
{
|
||||||
$inst = self::getInstance();
|
$inst = self::getInstance();
|
||||||
return $inst->getValue($key);
|
return $inst->getValue($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function set(string $key, mixed $value)
|
public static function set(string $key, mixed $value)
|
||||||
{
|
{
|
||||||
$inst = self::getInstance();
|
$inst = self::getInstance();
|
||||||
return $inst->setValue($key, $value);
|
return $inst->setValue($key, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user