public function __construct($view = '', $message = '', $code = 0, Exception $previous = NULL) { parent::__construct($message, $code, $previous); if (!starts_with(Atto::dir_app(), $view) && !starts_with(Atto::dir_htdocs(), $view)) { $view = Atto::makeAccessPath(array(Atto::dir_error(), Atto::dir_atto_error()), array($view)); } $this->view = $view; }
/** * cascade * * @method cascade * @param mixed $callback * @param array $options * @throws Exception */ public static function cascade($callback, array $options = array()) { // options init self::$_options = array_merge(self::$_options, $options); $init = create_function('', ' require Atto::dir_atto_common() . \'init.php\'; require Atto::dir_common() . \'init.php\';'); $init(); if (self::$_options['hide_gate']) { if (starts_with(Atto::gateScriptUri(), Atto::requestUri())) { AttoHttpHelper::redirect(Atto::uri()); } } // timezone if (function_exists('date_default_timezone_set')) { date_default_timezone_set(self::$_options['admin_teimezone']); } // error_log if (self::$_options['error_log']) { self::errorHandlerRegister(array('AttoErrorToLog', 'publish')); } set_error_handler(create_function('$errno , $errstr, $errfile, $errline, $errcontext', ' // callback foreach ( Atto::errorHandlerRegister() as $callback ) { $res = call_user_func( $callback, $errno , $errstr, $errfile, $errline, $errcontext ); if ( $res === false ) { return $res; } }')); if (function_exists('set_exception_handler')) { // exception_log if (self::$_options['exception_log']) { self::exceptionHandlerRegister(array('AttoExceptionToLog', 'publish')); } set_exception_handler(create_function('$e', ' // callback foreach ( Atto::exceptionHandlerRegister() as $callback ) { $res = call_user_func( $callback, $e ); if ( $res === false ) { return $res; } }')); } // gzip if (function_exists('ob_gzhandler')) { self::publishHandlerRegister(create_function('$content, $mode', ' $zlab_output_compression = ini_get( "zlib.output_compression" ); if ( !$zlab_output_compression || $zlab_output_compression == "0" || strtolower( $zlab_output_compression ) == "off" ) { $content_encoding = Atto::serchHeader( "/^Content-Encoding:/iu" ); if ( $content_encoding === false && Atto::isGzipContentType() ) { return ob_gzhandler( $content, $mode ); } } return $content;')); } set_include_path(get_include_path() . PATH_SEPARATOR . Atto::dir_app()); // callback if (!is_callable($callback)) { $callback = array($callback, '__invoke'); // PHP < 5.3 if (!is_callable($callback)) { throw new Exception('Callees of the callback is unknown'); } } // publishHandler ob_start(create_function('$content, $mode', ' // header Atto::overrideXpowerdBy(); if ( Atto::isDebug() ) { header( "ElapsedMicrotime: " . Atto::getElapsedMicrotime() ); } if ( class_exists( "AttoHttpHelper", false ) ) { AttoHttpHelper::outputHeaders(); } // callback foreach ( Atto::publishHandlerRegister() as $callback ) { $res = call_user_func( $callback, $content, $mode ); if ( $res !== false ) { $content = $res; } } return $content;')); ob_implicit_flush(false); try { self::_plugsInsertion(); call_user_func($callback, self::uri()); } catch (AttoAbstractHasRenderException $e) { $content = ob_get_contents(); if (!$content) { $content = ''; } else { ob_clean(); } $e->render($content); } catch (Exception $e) { $render = array($e, 'render'); if (is_callable($render)) { $content = ob_get_contents(); if (!$content) { $content = ''; } else { ob_clean(); } call_user_func($render, $content); } else { throw $e; } } ob_end_flush(); }