Тема: monstra/Core.php что это за безобразие?
Блуждал по просторам интернета, так сказать и наткнулся на вашу CMS, довольно не плохохие были впечатления от внешнего вида админки, что несоменно порадовало меня. Скачал. Открыл мануал на русском, тот что в гугл доках и принялся читать. Установил, все быстренько настроил, зашел в админку. Все так красиво, слов нет. Потыкал по кнопочкам, то проверил это. Глазу приятно, только верстка косится и едет, если за уголки браузера понятнуть.
Открыл папку в phpStorm, и полез смотреть код, быстро добрался до monstra/Core.php, вот что я увидел:
(Не хочу оскорблять никого, если что)
Почему код в ядре настолько ужасен?
Примеры:
А зачем тогда константы?
...
Да, да - вот эти:
class Core {
protected static $instance = null;
const PRODUCTION = 1;
const STAGING = 2;
const TESTING = 3;
const DEVELOPMENT = 4;
//.......И тут... где же они?
protected static function loadDefines() {
// тут
$environments = array(1 => 'production',
2 => 'staging',
3 => 'testing',
4 => 'development');
$root_defines = ROOT . DS . 'boot' . DS . 'defines.php';
$environment_defines = ROOT . DS . 'boot' . DS . $environments[Core::$environment] . DS . 'defines.php';
$monstra_defines = ROOT . DS . 'monstra' . DS . 'boot' . DS . 'defines.php';
if (file_exists($root_defines)) {
include $root_defines;
} elseif(file_exists($environment_defines)) {
include $environment_defines;
} elseif(file_exists($monstra_defines)) {
include $monstra_defines;
} else {
throw new RuntimeException("The defines file does not exist.");
}
}и тут.
И ище зачем повторять код???
protected static function loadPluggable() {
$environments = array(1 => 'production',
2 => 'staging',
3 => 'testing',
4 => 'development');
$root_pluggable = ROOT . DS . 'boot';
$environment_pluggable = ROOT . DS . 'boot' . DS . $environments[Core::$environment];
$monstra_pluggable = ROOT . DS . 'monstra' . DS . 'boot';
//почему не обернули в отдельную функцию?
if (file_exists($root_pluggable . DS . 'filters.php')) {
include $root_pluggable . DS . 'filters.php';
} elseif(file_exists($environment_pluggable . DS . 'filters.php')) {
include $environment_pluggable . DS . 'filters.php';
} elseif(file_exists($monstra_pluggable . DS . 'filters.php')) {
include $monstra_pluggable . DS . 'filters.php';
} else {
throw new RuntimeException("The pluggable file does not exist.");
}
if (file_exists($root_pluggable . DS . 'actions.php')) {
include $root_pluggable . DS . 'actions.php';
} elseif(file_exists($environment_pluggable . DS . 'actions.php')) {
include $environment_pluggable . DS . 'actions.php';
} elseif(file_exists($monstra_pluggable . DS . 'actions.php')) {
include $monstra_pluggable . DS . 'actions.php';
} else {
throw new RuntimeException("The pluggable file does not exist.");
}
if (file_exists($root_pluggable . DS . 'shortcodes.php')) {
include $root_pluggable . DS . 'shortcodes.php';
} elseif(file_exists($environment_pluggable . DS . 'shortcodes.php')) {
include $environment_pluggable . DS . 'shortcodes.php';
} elseif(file_exists($monstra_pluggable . DS . 'shortcodes.php')) {
include $monstra_pluggable . DS . 'shortcodes.php';
} else {
throw new RuntimeException("The pluggable file does not exist.");
}
}Про то, что в конструкторе я вообще промолчу.
public static function exceptionHandler($exception){...}Почему помешан код html\css\php ? Да еще в ядре, да и в таких масштабах. Зачем тогда вам mvc?
Собаки, сколько раз о них говорили
@header('Content-Type: text/html; charset=UTF-8');
@header('HTTP/1.1 500 Internal Server Error'); @file_put_contents(LOGS . DS . gmdate('Y_m_d') . '.log',
gmdate('Y/m/d H:i:s') . ' --- ' . '['.$error_type.']' . ' --- ' . $exception->getMessage() . ' --- ' . 'Exception thrown on line '.$exception->getLine().' in '.$exception->getFile() . "\n",
FILE_APPEND);requiere_once языковая конструкция, для которой скобки () совершенно не нужны, также как для include, include_once, require, echo, etc.
// Load Plugins API module
require_once(ENGINE . DS . 'plugins.php');
// Load Shortcodes API module
require_once(ENGINE . DS . 'shortcodes.php');Почему синтаксис, правила которого описаны в документации, не соблюдается?
Это малая толика того, что бросилось в глаза...
