src/Common/Service/ErrorHandler.php
public static function renderErrorView(
        $sView,
        $aData = [],
        $bFlushBuffer = true
    ) {

        //  Flush the output buffer
        if ($bFlushBuffer) {
            $sObContents = ob_get_contents();
            if (!empty($sObContents)) {
                ob_clean();
            }
        }

        $oInput = Factory::service('Input');
        $sType  = $oInput::isCli() ? 'cli' : 'html';
        $aPaths = [];

        $oRouter     = Factory::service('Router');
        $sController = ucfirst($oRouter->fetch_class());

        if (class_exists($sController)) {
            $oReflection     = new \ReflectionClass($sController);
            $sModuleViewPath = preg_replace('/controllers$/', '', dirname($oReflection->getFileName()));
            $aPaths[]        = implode(DIRECTORY_SEPARATOR, [
                rtrim($sModuleViewPath, DIRECTORY_SEPARATOR),
                'views',
                'errors',
                $sType,
                $sView . '.php',
            ]);
        }

        //  App generic
        $aPaths[] = implode(DIRECTORY_SEPARATOR, [
            NAILS_APP_PATH . 'application',
            'views',
            'errors',
            $sType,
            $sView . '.php',
        ]);

        //  Nails
        $aPaths[] = implode(DIRECTORY_SEPARATOR, [
            rtrim(NAILS_COMMON_PATH, DIRECTORY_SEPARATOR),
            'views',
            'errors',
            $sType,
            $sView . '.php',
        ]);

        $sValidPath = null;
        foreach ($aPaths as $sPath) {
            if (file_exists($sPath)) {
                $sValidPath = $sPath;
                break;
            }
        }

        if ($sValidPath) {

            $oView = Factory::service('View');
            $oView->setData($aData);
            echo $oView->load($sValidPath, [], true);

        } else {
            static::halt('404 Page Not Found', '', HttpCodes::STATUS_NOT_FOUND);
        }
    }
public static function renderErrorView(
        $sView,
        $aData = [],
        $bFlushBuffer = true
    ) {

        //  Flush the output buffer
        if ($bFlushBuffer) {
            $sObContents = ob_get_contents();
            if (!empty($sObContents)) {
                ob_clean();
            }
        }

        $oInput = Factory::service('Input');
        $sType  = $oInput::isCli() ? 'cli' : 'html';
        $aPaths = [];

        $oRouter     = Factory::service('Router');
        $sController = ucfirst($oRouter->fetch_class());

        if (class_exists($sController)) {
            $oReflection     = new \ReflectionClass($sController);
            $sModuleViewPath = preg_replace('/controllers$/', '', dirname($oReflection->getFileName()));
            $aPaths[]        = implode(DIRECTORY_SEPARATOR, [
                rtrim($sModuleViewPath, DIRECTORY_SEPARATOR),
                'views',
                'errors',
                $sType,
                $sView . '.php',
            ]);
        }

        //  App generic
        $aPaths[] = implode(DIRECTORY_SEPARATOR, [
            NAILS_APP_PATH . 'application',
            'views',
            'errors',
            $sType,
            $sView . '.php',
        ]);

        //  Nails
        $aPaths[] = implode(DIRECTORY_SEPARATOR, [
            rtrim(NAILS_COMMON_PATH, DIRECTORY_SEPARATOR),
            'views',
            'errors',
            $sType,
            $sView . '.php',
        ]);

        $sValidPath = null;
        foreach ($aPaths as $sPath) {
            if (file_exists($sPath)) {
                $sValidPath = $sPath;
                break;
            }
        }

        if ($sValidPath) {

            $oView = Factory::service('View');
            $oView->setData($aData);
            echo $oView->load($sValidPath, [], true);

        } else {
            static::halt('404 Page Not Found', '', HttpCodes::STATUS_NOT_FOUND);
        }
    }
public static function renderErrorView ( $ sView , $ aData = [ ] , $ bFlushBuffer = true ) { //  Flush the output buffer if ( $ bFlushBuffer ) { $ sObContents = ob_get_contents ( ) ; if ( ! empty ( $ sObContents ) ) { ob_clean ( ) ; } } $ oInput = Factory :: service ( 'Input' ) ; $ sType = $ oInput :: isCli ( ) ? 'cli' : 'html' ; $ aPaths = [ ] ; $ oRouter = Factory :: service ( 'Router' ) ; $ sController = ucfirst ( $ oRouter -> fetch_class ( ) ) ; if ( class_exists ( $ sController ) ) { $ oReflection = new \ ReflectionClass ( $ sController ) ; $ sModuleViewPath = preg_replace ( '/controllers$/' , '' , dirname ( $ oReflection -> getFileName ( ) ) ) ; $ aPaths [ ] = implode ( DIRECTORY_SEPARATOR , [ rtrim ( $ sModuleViewPath , DIRECTORY_SEPARATOR ) , 'views' , 'errors' , $ sType , $ sView . '.php' , ] ) ; } //  App generic $ aPaths [ ] = implode ( DIRECTORY_SEPARATOR , [ NAILS_APP_PATH . 'application' , 'views' , 'errors' , $ sType , $ sView . '.php' , ] ) ; //  Nails $ aPaths [ ] = implode ( DIRECTORY_SEPARATOR , [ rtrim ( NAILS_COMMON_PATH , DIRECTORY_SEPARATOR ) , 'views' , 'errors' , $ sType , $ sView . '.php' , ] ) ; $ sValidPath = null ; foreach ( $ aPaths as $ sPath ) { if ( file_exists ( $ sPath ) ) { $ sValidPath = $ sPath ; break ; } } if ( $ sValidPath ) { $ oView = Factory :: service ( 'View' ) ; $ oView -> setData ( $ aData ) ; echo $ oView -> load ( $ sValidPath , [ ] , true ) ; } else { static :: halt ( '404 Page Not Found' , '' , HttpCodes :: STATUS_NOT_FOUND ) ; } }
Renders the error view appropriate for the environment

@param string  $sView        The view to load
@param array   $aData        Data to make available to the view
@param boolean $bFlushBuffer Whether to flush the output buffer or not
Renders the error view appropriate for the environment