Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2. class Kohana extends Kohana_Core {
  3.  
  4.     public static function init(array $settings = NULL) {
  5.         // zend include_path
  6.         set_include_path(MODPATH.'zend/classes');
  7.  
  8.         parent::init($settings);
  9.     }
  10.  
  11.     public static function auto_load($class) {
  12.    
  13.         // zend
  14.         $ns = current(explode('_',$class));
  15.         if ('Zend' === $ns) {
  16.             return self::import(str_replace('_',DIRECTORY_SEPARATOR, $class));
  17.         }
  18.  
  19.         // namespace
  20.         $ns = (int) strpos($class,'\\');
  21.         if ($ns) {
  22.             return self::import(str_replace('\\',DIRECTORY_SEPARATOR, strtolower($class)));
  23.         }
  24.  
  25.         return parent::auto_load($class);
  26.     }
  27.  
  28.     private static function import($file) {
  29.    
  30.         if ($path = Kohana::find_file('classes',$file)) {
  31.             require $path;
  32.             return TRUE;
  33.         }
  34.  
  35.         return FALSE;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement