From 1360793ff7baae742e0f3646a54245eb95465efe Mon Sep 17 00:00:00 2001 From: Awilum Date: Sat, 2 Jun 2018 22:26:06 +0300 Subject: [PATCH] Flextype: new method setErrorHandler() added --- flextype/Flextype.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/flextype/Flextype.php b/flextype/Flextype.php index 779073e5..474a5398 100755 --- a/flextype/Flextype.php +++ b/flextype/Flextype.php @@ -86,10 +86,8 @@ class Flextype function_exists('mb_regex_encoding') and mb_regex_encoding(Registry::get('site.charset')); function_exists('mb_internal_encoding') and mb_internal_encoding(Registry::get('site.charset')); - // Set Error handler - set_error_handler('Flextype\Component\ErrorHandler\ErrorHandler::error'); - register_shutdown_function('Flextype\Component\ErrorHandler\ErrorHandler::fatal'); - set_exception_handler('Flextype\Component\ErrorHandler\ErrorHandler::exception'); + // Set error handler + Flextype::setErrorHandler(); // Set default timezone date_default_timezone_set(Registry::get('site.timezone')); @@ -113,6 +111,23 @@ class Flextype ob_end_flush(); } + /** + * Set error handler + * + * @access protected + */ + protected static function setErrorHandler() + { + // Create directory for logs + !Filesystem::fileExists(LOGS_PATH) and Filesystem::createDir(LOGS_PATH); + + // Set Error handler + set_error_handler('Flextype\Component\ErrorHandler\ErrorHandler::error'); + register_shutdown_function('Flextype\Component\ErrorHandler\ErrorHandler::fatal'); + set_exception_handler('Flextype\Component\ErrorHandler\ErrorHandler::exception'); + + } + /** * Return the Flextype instance. * Create it if it's not already created.