diff --git a/public_html/index.php b/public_html/index.php index 342c6e9..4a4adfa 100644 --- a/public_html/index.php +++ b/public_html/index.php @@ -27,5 +27,3 @@ switch($tipe) { require_once(DIR_SYSTEM.'system.php'); break; } - - diff --git a/system/database/Databases/MSSQL.php b/system/database/Databases/MSSQL.php index e597e2d..0c605f1 100644 --- a/system/database/Databases/MSSQL.php +++ b/system/database/Databases/MSSQL.php @@ -74,16 +74,19 @@ class MSSQL implements \Phacil\Framework\Databases\Api\DriverInterface } } + /** {@inheritdoc} */ public function escape($value) { return \mssql_real_escape_string($value, $this->connection); } + /** {@inheritdoc} */ public function countAffected() { return \mssql_rows_affected($this->connection); } + /** {@inheritdoc} */ public function getLastId() { $last_id = false; diff --git a/system/database/Databases/MySQL_PDO.php b/system/database/Databases/MySQL_PDO.php index 46a7410..99631e7 100644 --- a/system/database/Databases/MySQL_PDO.php +++ b/system/database/Databases/MySQL_PDO.php @@ -49,7 +49,7 @@ class MySQL_PDO implements DatabasesDriver private $params = array(); /** - * @inheritdoc + * {@inheritdoc} */ public function __construct($host, $user, $pass, $name, $port = '3306', $charset = 'utf8mb4') { @@ -88,9 +88,9 @@ class MySQL_PDO implements DatabasesDriver throw new \Phacil\Framework\Exception($exception->getMessage()); } } - + /** - * @inheritdoc + * {@inheritdoc} */ public function query($sql) { @@ -112,6 +112,7 @@ class MySQL_PDO implements DatabasesDriver * * @param mixed $string shielded line * @return string Returns shielded line or to FALSE , if the driver does not support screening + * @inheritdoc */ public function escape($string = null) { @@ -127,7 +128,7 @@ class MySQL_PDO implements DatabasesDriver } /** - * @inheritdoc + * {@inheritdoc} */ public function getLastId() { @@ -163,7 +164,7 @@ class MySQL_PDO implements DatabasesDriver } /** - * @inheritdoc + * {@inheritdoc} */ public function execute($sql, array $params = []) { diff --git a/system/database/Databases/MySQL_legacy.php b/system/database/Databases/MySQL_legacy.php index 7585cfc..3dd1cbc 100644 --- a/system/database/Databases/MySQL_legacy.php +++ b/system/database/Databases/MySQL_legacy.php @@ -78,21 +78,24 @@ class MySQL_legacy implements \Phacil\Framework\Databases\Api\DriverInterface { throw new \Phacil\Framework\Exception('Error: ' . \mysql_error($this->connection) . '
Error No: ' . mysql_errno($this->connection) . '
' . $sql); } } - + + /** {@inheritdoc} */ public function escape($value) { return \mysql_real_escape_string($value, $this->connection); } - + + /** {@inheritdoc} */ public function countAffected() { return \mysql_affected_rows($this->connection); } + /** {@inheritdoc} */ public function getLastId() { return \mysql_insert_id($this->connection); } /** - * @inheritdoc + * {@inheritdoc} */ public function execute($sql, array $params = []) { diff --git a/system/database/Databases/MySQLi.php b/system/database/Databases/MySQLi.php index c74b076..1a235c8 100644 --- a/system/database/Databases/MySQLi.php +++ b/system/database/Databases/MySQLi.php @@ -35,14 +35,7 @@ class MySQLi implements DriverInterface { const DB_TYPE_ID = self::LIST_DB_TYPE_ID['MYSQL']; /** - * @param string $hostname - * @param string $username - * @param string $password - * @param string $database - * @param string $port - * @param string $charset - * @return void - * @throws \Phacil\Framework\Exception + * {@inheritdoc} */ public function __construct($hostname, $username, $password, $database, $port = '3306', $charset = 'utf8mb4') { try { @@ -81,10 +74,7 @@ class MySQLi implements DriverInterface { } /** - * Execute the SQl Query - * @param string $sql - * @return \Phacil\Framework\Databases\Object\ResultInterface|true - * @throws \Phacil\Framework\Exception + * {@inheritdoc} */ public function query($sql) { $query = $this->connection->query($sql); @@ -102,47 +92,31 @@ class MySQLi implements DriverInterface { throw new \Phacil\Framework\Exception('Error: ' . $this->connection->error . '
Error No: ' . $this->connection->errno . '
' . $sql); } } - + /** - * Important escape to prevent SQL injection. - * - * @param string $value - * @return string + * {@inheritdoc} */ public function escape($value) { return $this->connection->real_escape_string($value); } - - /** - * Number of affected rows - * - * @return int */ + + /** {@inheritdoc} */ public function countAffected() { return $this->connection->affected_rows; } - /** @return int|string */ + /** {@inheritdoc} */ public function getLastId() { return $this->connection->insert_id; } - - /** @return bool */ + + /** {@inheritdoc} */ public function isConnected() { return $this->connection->ping(); } - - /** @return void */ - public function __destruct() { - //$this->connection->close(); - } /** - * Execute a prepared statement with parameters - * - * @param string $sql SQL query with named placeholders - * @param array $params Associative array of parameters - * @return \Phacil\Framework\Databases\Object\ResultInterface|true - * @throws \Phacil\Framework\Exception + * {@inheritdoc} */ public function execute($sql, array $params = []) { diff --git a/system/database/Databases/Object/ResultCacheIterator.php b/system/database/Databases/Object/ResultCacheIterator.php index 2f8e02c..3db3eca 100644 --- a/system/database/Databases/Object/ResultCacheIterator.php +++ b/system/database/Databases/Object/ResultCacheIterator.php @@ -30,7 +30,6 @@ class ResultCacheIterator extends \CachingIterator implements ResultInterface { */ public $data = null; - /** * * @var \Phacil\Framework\Databases\Object\Result diff --git a/system/database/Databases/Oracle.php b/system/database/Databases/Oracle.php index b0d0f1b..c550027 100644 --- a/system/database/Databases/Oracle.php +++ b/system/database/Databases/Oracle.php @@ -33,16 +33,9 @@ class Oracle implements Databases { */ protected $error; - + /** - * @param string $hostname - * @param string $username - * @param string $password - * @param string $database - * @param string $port - * @param string $charset - * @return void - * @throws Exception + * {@inheritdoc} */ public function __construct($hostname, $username, $password, $database, $port = '1521', $charset = 'utf8') { $this->connection = \oci_connect($username, $password, $hostname.":".$port."/".$database, $charset); @@ -56,12 +49,9 @@ class Oracle implements Databases { //oci_set_client_identifier($this->connection, $cid); } - + /** - * - * @param string $sql - * @return \Phacil\Framework\Databases\Object\ResultInterface|true - * @throws \Phacil\Framework\Exception + * {@inheritdoc} */ public function query($sql) { $stid = \oci_parse($this->connection, $sql); @@ -80,29 +70,31 @@ class Oracle implements Databases { throw new \Phacil\Framework\Exception('Error: ' . oci_error() . '
' . $sql); } } - + + /** + * {@inheritdoc} + */ public function escape($value) { return str_replace("'", "", $value); } - + + /** {@inheritdoc} */ public function countAffected() { return NULL; } + + /** {@inheritdoc} */ public function getLastId() { return NULL; } - + + /** {@inheritdoc} */ public function isConnected() { return $this->connection; } /** - * Execute a prepared statement with parameters - * - * @param string $sql SQL query with named placeholders - * @param array $params Associative array of parameters - * @return \Phacil\Framework\Databases\Object\ResultInterface|true - * @throws \Phacil\Framework\Exception + * {@inheritdoc} */ public function execute($sql, array $params = []) { diff --git a/system/database/Databases/Oracle_PDO.php b/system/database/Databases/Oracle_PDO.php index de2c5db..837655c 100644 --- a/system/database/Databases/Oracle_PDO.php +++ b/system/database/Databases/Oracle_PDO.php @@ -56,6 +56,7 @@ class Oracle_PDO implements DriverInterface */ private $statement = null; + /** {@inheritdoc} */ public function __construct($hostname, $username, $password, $database, $port = '1521', $charset = 'UTF8') { try { @@ -71,10 +72,12 @@ class Oracle_PDO implements DriverInterface } $this->rowCount = 0; } + public function prepare($sql) { $this->statement = $this->connection->prepare($sql); } + public function bindParam($parameter, $variable, $data_type = \PDO::PARAM_STR, $length = 0) { if ($length) { @@ -84,6 +87,7 @@ class Oracle_PDO implements DriverInterface } } + /** {@inheritdoc} */ public function query($sql, $params = array()) { $this->statement = $this->connection->prepare($sql); @@ -120,10 +124,14 @@ class Oracle_PDO implements DriverInterface return $result; } } + + /** {@inheritdoc} */ public function escape($value) { return str_replace(array("\\", "\0", "\n", "\r", "\x1a", "'", '"'), array("\\\\", "\\0", "\\n", "\\r", "\Z", "\'", '\"'), $value); } + + /** {@inheritdoc} */ public function countAffected() { if ($this->statement) { @@ -132,11 +140,14 @@ class Oracle_PDO implements DriverInterface return $this->rowCount; } } + + /** {@inheritdoc} */ public function getLastId() { return $this->connection->lastInsertId(); } + /** {@inheritdoc} */ public function isConnected() { if ($this->connection) { @@ -147,12 +158,7 @@ class Oracle_PDO implements DriverInterface } /** - * Execute a prepared statement with parameters - * - * @param string $sql SQL query with named placeholders - * @param array $params Associative array of parameters - * @return \Phacil\Framework\Databases\Object\ResultInterface|true - * @throws \Phacil\Framework\Exception + * {@inheritdoc} */ public function execute($sql, array $params = []) { diff --git a/system/database/Databases/Postgre.php b/system/database/Databases/Postgre.php index 6d5489a..2f38c68 100644 --- a/system/database/Databases/Postgre.php +++ b/system/database/Databases/Postgre.php @@ -24,7 +24,7 @@ class Postgre implements DriverInterface { private $link; /** - * @inheritdoc + * {@inheritdoc} */ public function __construct($hostname, $username, $password, $database, $port = '5432', $charset = 'UTF8') { if (!$this->link = pg_connect('host=' . $hostname . ' port=' . $port . ' user=' . $username . ' password=' . $password . ' dbname=' . $database)) { @@ -41,10 +41,7 @@ class Postgre implements DriverInterface { } /** - * - * @param string $sql - * @return \Phacil\Framework\Databases\Object\ResultInterface|true - * @throws \Phacil\Framework\Exception + * {@inheritdoc} */ public function query($sql) { $resource = pg_query($this->link, $sql); @@ -71,22 +68,21 @@ class Postgre implements DriverInterface { throw new \Phacil\Framework\Exception('Error: ' . pg_result_error($this->link) . '
' . $sql); } } - + /** - * @param string $value - * @return string + * {@inheritdoc} */ public function escape($value) { return pg_escape_string($this->link, $value); } - - /** @return int */ + + /** {@inheritdoc} */ public function countAffected() { return pg_affected_rows($this->link); } - + /** - * @inheritdoc + * {@inheritdoc} */ public function getLastId() { $query = $this->query("SELECT LASTVAL() AS `id`"); diff --git a/system/database/Databases/SQLSRV.php b/system/database/Databases/SQLSRV.php index 52b5f36..7e88f0f 100644 --- a/system/database/Databases/SQLSRV.php +++ b/system/database/Databases/SQLSRV.php @@ -24,7 +24,7 @@ class SQLSRV implements DriverInterface { private $link; /** - * @inheritdoc + * {@inheritdoc} */ public function __construct($hostname, $username, $password, $database, $port = '1443', $charset = 'utf8') { /* @@ -55,8 +55,7 @@ class SQLSRV implements DriverInterface { } /** - * - * @inheritdoc + * {@inheritdoc} */ public function query($sql) { $resource = \sqlsrv_query($this->link, $sql); diff --git a/system/database/Databases/SQLite3.php b/system/database/Databases/SQLite3.php index 4979f04..af8cc28 100644 --- a/system/database/Databases/SQLite3.php +++ b/system/database/Databases/SQLite3.php @@ -24,15 +24,7 @@ class SQLite3 implements DriverInterface { private $connection; /** - * - * @param string $hostname - * @param string $username - * @param string $password - * @param string $database - * @param string $port - * @param string $charset - * @return void - * @throws \Phacil\Framework\Exception + * {@inheritdoc} */ public function __construct($hostname, $username = null, $password = null, $database, $port = '3306', $charset = 'utf8mb4') { @@ -45,9 +37,7 @@ class SQLite3 implements DriverInterface { /** * - * @param string $sql - * @return \Phacil\Framework\Databases\Object\ResultInterface|true - * @throws \Phacil\Framework\Exception + * @inheritdoc */ public function query($sql){ //$query = $this->connection->query($sql); @@ -79,35 +69,29 @@ class SQLite3 implements DriverInterface { } /** - * @param string $value - * @return string + * {@inheritdoc} */ public function escape($value) { return $this->connection->escapeString($value); } - /** @return int */ + /** {@inheritdoc} */ public function countAffected() { return $this->connection->changes(); } - - /** @return int */ + + /** {@inheritdoc} */ public function getLastId() { return $this->connection->lastInsertRowID(); } - /** @return bool */ + /** {@inheritdoc} */ public function isConnected() { return ($this->connection) ? true : false; } /** - * Execute a prepared statement with parameters - * - * @param string $sql SQL query with named placeholders - * @param array $params Associative array of parameters - * @return \Phacil\Framework\Databases\Object\ResultInterface|true - * @throws \Phacil\Framework\Exception + * {@inheritdoc} */ public function execute($sql, array $params = []) { diff --git a/system/database/Databases/mPDO.php b/system/database/Databases/mPDO.php index 2731c0a..8c59a4e 100644 --- a/system/database/Databases/mPDO.php +++ b/system/database/Databases/mPDO.php @@ -105,9 +105,13 @@ class mPDO implements DriverInterface { return $result; } } + + /** {@inheritdoc} */ public function escape($value) { return str_replace(array("\\", "\0", "\n", "\r", "\x1a", "'", '"'), array("\\\\", "\\0", "\\n", "\\r", "\Z", "\'", '\"'), $value); } + + /** {@inheritdoc} */ public function countAffected() { if ($this->statement) { return $this->statement->rowCount(); @@ -115,6 +119,8 @@ class mPDO implements DriverInterface { return $this->rowCount; } } + + /** {@inheritdoc} */ public function getLastId() { return $this->connection->lastInsertId(); } @@ -131,12 +137,7 @@ class mPDO implements DriverInterface { } /** - * Execute a prepared statement with parameters - * - * @param string $sql SQL query with named placeholders - * @param array $params Associative array of parameters - * @return \Phacil\Framework\Databases\Object\ResultInterface|true - * @throws \Phacil\Framework\Exception + * {@inheritdoc} */ public function execute($sql, array $params = []) { diff --git a/system/database/Databases/nullStatement.php b/system/database/Databases/nullStatement.php index e172c6a..83e401c 100644 --- a/system/database/Databases/nullStatement.php +++ b/system/database/Databases/nullStatement.php @@ -38,19 +38,19 @@ final class nullStatement implements DriverInterface { return self::DB_TYPE_ID; } + /** {@inheritdoc} */ public function __construct($hostname, $username, $password, $database, $charset = 'utf8mb4') { //$this->connection = NULL; } + /** {@inheritdoc} */ public function isConnected() { return false; } /** - * - * @param string $sql - * @return \Phacil\Framework\Databases\Object\ResultInterface|true + * {@inheritdoc} */ public function query($sql) { $result = new \Phacil\Framework\Databases\Object\Result(); @@ -60,25 +60,23 @@ final class nullStatement implements DriverInterface { return $result; } + /** {@inheritdoc} */ public function escape($value) { return NULL; } + /** {@inheritdoc} */ public function countAffected() { return NULL; } + /** {@inheritdoc} */ public function getLastId() { return NULL; } /** - * Execute a prepared statement with parameters - * - * @param string $sql SQL query with named placeholders - * @param array $params Associative array of parameters - * @return null - * @throws \Phacil\Framework\Exception + * {@inheritdoc} */ public function execute($sql, array $params = []) { diff --git a/system/database/Databases/sqlsrvPDO.php b/system/database/Databases/sqlsrvPDO.php index 1e877b1..9a33946 100644 --- a/system/database/Databases/sqlsrvPDO.php +++ b/system/database/Databases/sqlsrvPDO.php @@ -72,8 +72,7 @@ class sqlsrvPDO implements DriverInterface { } /** - * - * @inheritdoc + * {@inheritdoc} */ public function query($sql, $params = array()) { $this->statement = $this->connection->prepare($sql); @@ -108,7 +107,7 @@ class sqlsrvPDO implements DriverInterface { } /** - * @inheritdoc + * {@inheritdoc} */ public function escape($value) { return str_replace(array("\\", "\0", "\n", "\r", "\x1a", "'", '"'), array("\\\\", "\\0", "\\n", "\\r", "\Z", "\'", '\"'), $value); diff --git a/system/engine/api/document.php b/system/engine/api/document.php new file mode 100644 index 0000000..be858e3 --- /dev/null +++ b/system/engine/api/document.php @@ -0,0 +1,76 @@ +title = $title; } } - - /** @return string */ + + /** {@inheritdoc} */ public function getTitle() { return $this->title; } - + /** - * @param string $description - * @return void + * {@inheritdoc} */ public function setDescription($description) { $this->description = $description; } - - /** @return string */ + + /** {@inheritdoc} */ public function getDescription() { return $this->description; } - + /** - * @param string $keywords - * @return void + * {@inheritdoc} */ public function setKeywords($keywords) { $this->keywords = $keywords; } - - /** @return string */ + + /** {@inheritdoc} */ public function getKeywords() { return $this->keywords; } - + /** - * @param string $href - * @param string $rel - * @return void + * {@inheritdoc} */ public function addLink($href, $rel) { $this->links[md5($href)] = array( @@ -74,8 +70,8 @@ class Document { 'rel' => $rel ); } - - /** @return array */ + + /** {@inheritdoc} */ public function getLinks() { return $this->links; } @@ -93,15 +89,10 @@ class Document { } return $var; - } - + /** - * @param string $href - * @param string $rel - * @param string $media - * @param bool $minify - * @return void + * {@inheritdoc} */ public function addStyle($href, $rel = 'stylesheet', $media = 'screen', $minify = true) { @@ -115,25 +106,22 @@ class Document { 'media' => $media ); } - - /** @return array */ + + /** {@inheritdoc} */ public function getStyles() { return $this->styles; - } - + } + /** - * @param string $script - * @param int|string $sort - * @param bool $minify - * @return void + * {@inheritdoc} */ public function addScript($script, $sort = 0, $minify = true) { if($minify) $script = $this->cacheMinify($script, 'js'); $script = $this->checkCDN($script); $this->scripts[($sort)][md5($script)] = $script; } - - /** @return array */ + + /** {@inheritdoc} */ public function getScripts() { $a = $this->scripts; ksort($a); @@ -194,47 +182,47 @@ class Document { mkdir($dirCache, 0755, true); } - if (file_exists($file) and Config::CACHE_MINIFY()) { - if($type == "js") { - if(file_exists($cachedFile) and Config::CACHE_JS_CSS()) { - return $cacheFile; - } else { - - include_once Config::DIR_SYSTEM()."ecompress/JSMin.php"; - - $buffer = file_get_contents($file); - - $buffer = preg_replace('//Uis', '', $buffer); - - $buffer = \JSMin::minify($buffer); - - file_put_contents($cachedFile, $buffer); - - return $cacheFile; - - } - - - }elseif($type == "css") { - if(file_exists($cachedFile) && Config::CACHE_JS_CSS()) { - return $cacheFile; - } else { - - include_once Config::DIR_SYSTEM()."ecompress/cssMin.php"; - - $buffer = file_get_contents($file); - - $buffer = minimizeCSS($buffer); - - file_put_contents($cachedFile, $buffer); - - return $cacheFile; - - } - - } else { - return $ref; - } + if (is_file($file) and Config::CACHE_MINIFY()) { + switch ($type) { + case 'js': + if (file_exists($cachedFile) and Config::CACHE_JS_CSS()) { + return $cacheFile; + } else { + $buffer = file_get_contents($file); + + $buffer = preg_replace('//Uis', '', $buffer); + + /** @var \Phacil\Framework\ECompress\JSMin */ + $buffer = \Phacil\Framework\Registry::getInstance()->create(\Phacil\Framework\ECompress\JSMin::class, [$buffer]); + + $buffer = $buffer->min(); + + file_put_contents($cachedFile, $buffer); + + return $cacheFile; + } + break; + case 'css': + if (file_exists($cachedFile) && Config::CACHE_JS_CSS()) { + return $cacheFile; + } else { + $buffer = file_get_contents($file); + + if($buffer){ + /** @var \Phacil\Framework\ECompress\cssMin */ + $cssMin = \Phacil\Framework\Registry::getInstance()->getInstance(\Phacil\Framework\ECompress\cssMin::class); + + file_put_contents($cachedFile, $cssMin->minify($buffer)); + + return $cacheFile; + } + return $ref; + } + break; + default: + return $ref; + break; + } } else { return $ref; } diff --git a/system/engine/interfaces/common/registers.php b/system/engine/interfaces/common/registers.php index d80d614..b6a33ba 100644 --- a/system/engine/interfaces/common/registers.php +++ b/system/engine/interfaces/common/registers.php @@ -23,7 +23,7 @@ namespace Phacil\Framework\Interfaces\Common; * @property \Phacil\Framework\Log $log * @property \Phacil\Framework\Caches $cache * @property \Phacil\Framework\Response $response - * @property \Phacil\Framework\Document $document + * @property \Phacil\Framework\Api\Document $document * @property \Phacil\Framework\Front $front * @property \Phacil\Framework\Translate $translate * @package Phacil\Framework\Interfaces diff --git a/system/engine/interfaces/serializer.php b/system/engine/interfaces/serializer.php index 15a271a..a79b4b5 100644 --- a/system/engine/interfaces/serializer.php +++ b/system/engine/interfaces/serializer.php @@ -22,7 +22,7 @@ interface Serializer * * @param string|int|float|bool|array|null $data * @return string|bool - * @throws \InvalidArgumentException + * @throws \Phacil\Framework\Exception\InvalidArgumentException * @since 2.0.0 */ public function serialize($data); @@ -32,7 +32,7 @@ interface Serializer * * @param string $string * @return string|int|float|bool|array|null - * @throws \InvalidArgumentException + * @throws \Phacil\Framework\Exception\InvalidArgumentException * @since 2.0.0 */ public function unserialize($string); diff --git a/system/etc/preferences.json b/system/etc/preferences.json index c78c3ab..f7c52e1 100644 --- a/system/etc/preferences.json +++ b/system/etc/preferences.json @@ -7,6 +7,7 @@ "Phacil\\Framework\\Api\\Database": "Phacil\\Framework\\Database", "Cm\\RedisSession\\Handler\\ConfigInterface": "Phacil\\Framework\\Session\\Redis\\Config", "Cm\\RedisSession\\Handler\\LoggerInterface": "Phacil\\Framework\\Session\\Redis\\Logger", - "Phacil\\Framework\\Mail\\Api\\MailInterface": "Phacil\\Framework\\Mail" + "Phacil\\Framework\\Mail\\Api\\MailInterface": "Phacil\\Framework\\Mail", + "Phacil\\Framework\\Api\\Document": "Phacil\\Framework\\Document" } } \ No newline at end of file diff --git a/system/json/autoload.php b/system/json/autoload.php index f044108..c93fe0a 100644 --- a/system/json/autoload.php +++ b/system/json/autoload.php @@ -26,14 +26,14 @@ class Json implements Serializer * * @param string|int|float|bool|array|null $data * @return string|bool - * @throws \InvalidArgumentException + * @throws \Phacil\Framework\Exception\InvalidArgumentException * @since 2.0.0 */ static public function encode($data) { $result = \json_encode($data); if (false === $result) { - throw new \InvalidArgumentException("Unable to serialize value. Error: " . self::json_last_error_msg()); + throw new \Phacil\Framework\Exception\InvalidArgumentException("Unable to serialize value. Error: " . self::json_last_error_msg()); } return $result; } @@ -43,14 +43,14 @@ class Json implements Serializer * * @param string $string * @return string|int|float|bool|array|null - * @throws \InvalidArgumentException + * @throws \Phacil\Framework\Exception\InvalidArgumentException * @since 2.0.0 */ static public function decode($string, $array = true) { $result = \json_decode($string, $array); if (json_last_error() !== JSON_ERROR_NONE) { - throw new \InvalidArgumentException("Unable to unserialize value. Error: " . self::json_last_error_msg()); + throw new \Phacil\Framework\Exception\InvalidArgumentException("Unable to unserialize value. Error: " . self::json_last_error_msg()); } return $result; } diff --git a/system/system.php b/system/system.php index 8cfc94d..d6e73f0 100644 --- a/system/system.php +++ b/system/system.php @@ -352,23 +352,33 @@ final class startEngineExacTI { * @return true|null */ public function checkRegistry($key){ - //mail - if(!isset($this->registry->$key) && $key == 'mail'){ - /** @var \Phacil\Framework\Mail\Api\MailInterface */ - $this->mail = $this->registry->getInstance(\Phacil\Framework\Mail\Api\MailInterface::class); - } - - // Translate - if(!isset($this->registry->$key) && $key == 'translate'){ - $this->translate = $this->registry->getInstance(\Phacil\Framework\Translate::class); - } - - // Session - if(!isset($this->registry->$key) && $key == 'session'){ - $this->session = $this->registry->getInstance(\Phacil\Framework\Session::class); - } + if(isset($this->registry->$key)) return $this->registry->$key; + + switch ($key) { + case 'mail': + /** @var \Phacil\Framework\Mail\Api\MailInterface */ + $this->registry->$key = $this->registry->getInstance(\Phacil\Framework\Mail\Api\MailInterface::class); + break; + + case 'translate': + $this->registry->$key = $this->registry->getInstance(\Phacil\Framework\Translate::class); + break; + + case 'session': + $this->registry->$key = $this->registry->getInstance(\Phacil\Framework\Session::class); + break; + + case 'document': + /** @var \Phacil\Framework\Api\Document */ + $this->registry->$key = $this->registry->getInstance(\Phacil\Framework\Api\Document::class); + break; + + default: + $objectToCreate = false; + break; + } - return (isset($this->registry->$key)) ?: NULL; + return isset($this->registry->$key) ? $this->registry->$key : null; } /** @return \Phacil\Framework\Registry */ @@ -537,9 +547,6 @@ if($engine->config->get('config_compression')) // Session $engine->session = $engine->getRegistry()->create(\Phacil\Framework\Session::class); -// Document -$engine->document = new Document(); - // Custom registrations $engine->extraRegistrations();