src/Common/Service/ErrorHandler.php
public static function init()
    {
        if (static::$bIsReady) {
            return;
        }

        $aErrorHandlers = Components::drivers('nails/common', 'ErrorHandler');
        $oDefaultDriver = null;
        $aCustomDrivers = [];
        foreach ($aErrorHandlers as $oErrorHandler) {
            if ($oErrorHandler->slug == static::DEFAULT_ERROR_HANDLER) {
                $oDefaultDriver = $oErrorHandler;
            } else {
                $aCustomDrivers[] = $oErrorHandler;
            }
        }

        if (count($aCustomDrivers) > 1) {
            $aNames = [];
            foreach ($aCustomDrivers as $oErrorHandler) {
                $aNames[] = $oErrorHandler->slug;
            }
            static::halt(implode(', ', $aNames), 'More than one error handler installed');
            return;
        } elseif (count($aCustomDrivers) === 1) {
            $oErrorHandler = reset($aCustomDrivers);
        } else {
            $oErrorHandler = $oDefaultDriver;
        }

        $sDriverNamespace = ArrayHelper::getFromArray('namespace', (array) $oErrorHandler->data);
        $sDriverClass     = ArrayHelper::getFromArray('class', (array) $oErrorHandler->data);
        $sClassName       = '\\' . $sDriverNamespace . $sDriverClass;

        if (!class_exists($sClassName)) {
            static::halt('Expected: ' . $sClassName, 'Driver class not available');
        } elseif (!in_array(static::INTERFACE_NAME, class_implements($sClassName))) {
            static::halt('Error Handler "' . $sClassName . '"  must implement "' . static::INTERFACE_NAME . '"');
        }

        $sClassName::init();

        static::$sDriverClass   = $sClassName;
        static::$oDefaultDriver = $oDefaultDriver;

        static::setHandlers();

        static::$bIsReady = true;
    }
public static function init()
    {
        if (static::$bIsReady) {
            return;
        }

        $aErrorHandlers = Components::drivers('nails/common', 'ErrorHandler');
        $oDefaultDriver = null;
        $aCustomDrivers = [];
        foreach ($aErrorHandlers as $oErrorHandler) {
            if ($oErrorHandler->slug == static::DEFAULT_ERROR_HANDLER) {
                $oDefaultDriver = $oErrorHandler;
            } else {
                $aCustomDrivers[] = $oErrorHandler;
            }
        }

        if (count($aCustomDrivers) > 1) {
            $aNames = [];
            foreach ($aCustomDrivers as $oErrorHandler) {
                $aNames[] = $oErrorHandler->slug;
            }
            static::halt(implode(', ', $aNames), 'More than one error handler installed');
            return;
        } elseif (count($aCustomDrivers) === 1) {
            $oErrorHandler = reset($aCustomDrivers);
        } else {
            $oErrorHandler = $oDefaultDriver;
        }

        $sDriverNamespace = ArrayHelper::getFromArray('namespace', (array) $oErrorHandler->data);
        $sDriverClass     = ArrayHelper::getFromArray('class', (array) $oErrorHandler->data);
        $sClassName       = '\\' . $sDriverNamespace . $sDriverClass;

        if (!class_exists($sClassName)) {
            static::halt('Expected: ' . $sClassName, 'Driver class not available');
        } elseif (!in_array(static::INTERFACE_NAME, class_implements($sClassName))) {
            static::halt('Error Handler "' . $sClassName . '"  must implement "' . static::INTERFACE_NAME . '"');
        }

        $sClassName::init();

        static::$sDriverClass   = $sClassName;
        static::$oDefaultDriver = $oDefaultDriver;

        static::setHandlers();

        static::$bIsReady = true;
    }
public static function init ( ) { if ( static :: $ bIsReady ) { return ; } $ aErrorHandlers = Components :: drivers ( 'nails/common' , 'ErrorHandler' ) ; $ oDefaultDriver = null ; $ aCustomDrivers = [ ] ; foreach ( $ aErrorHandlers as $ oErrorHandler ) { if ( $ oErrorHandler -> slug == static :: DEFAULT_ERROR_HANDLER ) { $ oDefaultDriver = $ oErrorHandler ; } else { $ aCustomDrivers [ ] = $ oErrorHandler ; } } if ( count ( $ aCustomDrivers ) > 1 ) { $ aNames = [ ] ; foreach ( $ aCustomDrivers as $ oErrorHandler ) { $ aNames [ ] = $ oErrorHandler -> slug ; } static :: halt ( implode ( ', ' , $ aNames ) , 'More than one error handler installed' ) ; return ; } elseif ( count ( $ aCustomDrivers ) === 1 ) { $ oErrorHandler = reset ( $ aCustomDrivers ) ; } else { $ oErrorHandler = $ oDefaultDriver ; } $ sDriverNamespace = ArrayHelper :: getFromArray ( 'namespace' , ( array ) $ oErrorHandler -> data ) ; $ sDriverClass = ArrayHelper :: getFromArray ( 'class' , ( array ) $ oErrorHandler -> data ) ; $ sClassName = '\\' . $ sDriverNamespace . $ sDriverClass ; if ( ! class_exists ( $ sClassName ) ) { static :: halt ( 'Expected: ' . $ sClassName , 'Driver class not available' ) ; } elseif ( ! in_array ( static :: INTERFACE_NAME , class_implements ( $ sClassName ) ) ) { static :: halt ( 'Error Handler "' . $ sClassName . '"  must implement "' . static :: INTERFACE_NAME . '"' ) ; } $ sClassName :: init ( ) ; static :: $ sDriverClass = $ sClassName ; static :: $ oDefaultDriver = $ oDefaultDriver ; static :: setHandlers ( ) ; static :: $ bIsReady = true ; }
Sets up the appropriate error handling driver
Sets up the appropriate error handling driver