Changeset 1754

Show
Ignore:
Timestamp:
01/20/2008 05:14:16 PM (9 months ago)
Author:
Shadowhand
Message:

Follow up to r1753:

  • Removed URI::construct()
  • Loader, URI, and Input will only be loaded for the first Controller
  • Slight optimizations to Kohana::instance()
Location:
trunk/system
Files:
4 modified

Legend:

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

    r1753 r1754  
    1313 
    1414        // The singleton instance of the controller 
    15         public static $instance = NULL; 
     15        public static $instance; 
    1616 
    1717        // Output buffering level 
     
    177177        final public static function & instance() 
    178178        { 
    179                 if (self::$instance == FALSE) 
     179                if (self::$instance === NULL) 
    180180                { 
    181181                        Benchmark::start(SYSTEM_BENCHMARK.'_controller_setup'); 
     
    228228                        } 
    229229 
    230                         // Load the controller 
    231                         $controller = new $controller(); 
     230                        // Initialize the controller 
     231                        $controller = new $controller; 
    232232 
    233233                        // Run system.post_controller_constructor 
  • trunk/system/libraries/Controller.php

    r1753 r1754  
    1010class Controller_Core { 
    1111 
    12         // Always loaded libraries 
    13         public $load; 
    14         public $uri; 
    15         public $input; 
    16  
    1712        /** 
    1813         * Constructor: __construct 
     
    2116        public function __construct() 
    2217        { 
    23                 if (Kohana::$instance == FALSE) 
     18                if (empty(Kohana::$instance)) 
    2419                { 
     20                        // Set the instance to the first controller loaded 
    2521                        Kohana::$instance = $this; 
     22 
     23                        // Loader should always be available 
     24                        $this->load = new Loader; 
     25 
     26                        // URI should always be available 
     27                        $this->uri = new URI; 
     28 
     29                        // Input should always be available 
     30                        $this->input = new Input; 
    2631                } 
    27  
    28                 // Loader should always be available 
    29                 $this->load = new Loader(); 
    30  
    31                 // URI should always be available 
    32                 $this->uri = new URI(); 
    33  
    34                 // Input should always be available 
    35                 $this->input = new Input(); 
    3632        } 
    3733 
  • trunk/system/libraries/Input.php

    r1672 r1754  
    1010class Input_Core { 
    1111 
     12        // Singleton instance 
    1213        protected static $instance; 
    1314 
  • trunk/system/libraries/URI.php

    r1672 r1754  
    1111 
    1212        /** 
    13          * Constructor. 
    14          */ 
    15         public function __construct() 
    16         { 
    17                 Log::add('debug', 'URI library initialized.'); 
     13         * Returns a singleton instance of URI. 
     14         * 
     15         * @return  object 
     16         */ 
     17        public static function instance() 
     18        { 
     19                static $instance; 
     20 
     21                // Initialize the URI instance 
     22                empty($instance) and $instance = new URI; 
     23 
     24                return $instance; 
    1825        } 
    1926