Changeset 2981

Show
Ignore:
Timestamp:
07/07/2008 12:51:57 PM (3 months ago)
Author:
Shadowhand
Message:

Added Kohana::close_buffers(), set Kohana::shutdown() to call close_buffers() rather than manually closing them.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/system/core/Kohana.php

    r2978 r2981  
    334334 
    335335        /** 
     336         * Closes all open output buffers, either by flushing or cleaning all 
     337         * open buffers, including the Kohana output buffer. 
     338         * 
     339         * @param   boolean  disable to clear buffers, rather than flushing 
     340         * @return  void 
     341         */ 
     342        public static function close_buffers($flush = TRUE) 
     343        { 
     344                if (ob_get_level() >= self::$buffer_level) 
     345                { 
     346                        // Set the close function 
     347                        $close = ($flush === TRUE) ? 'ob_end_flush' : 'ob_end_clean'; 
     348 
     349                        while (ob_get_level() > self::$buffer_level) 
     350                        { 
     351                                // Flush or clean the buffer 
     352                                $close(); 
     353                        } 
     354 
     355                        // This will flush the Kohana buffer, which sets self::$output 
     356                        ob_end_clean(); 
     357                } 
     358        } 
     359 
     360        /** 
    336361         * Triggers the shutdown of Kohana by closing the output buffer, runs the system.display event. 
    337362         * 
     
    340365        public static function shutdown() 
    341366        { 
    342                 while (ob_get_level() > self::$buffer_level) 
    343                 { 
    344                         // Flush all open output buffers above the internal buffer 
    345                         ob_end_flush(); 
    346                 } 
    347  
    348                 // This will flush the Kohana buffer, which sets self::$output 
    349                 (ob_get_level() === self::$buffer_level) and ob_end_clean(); 
     367                // Close output buffers 
     368                self::close_buffers(TRUE); 
    350369 
    351370                // Run the output event