HandlebarsAutoloader

Autloader for handlebars.php.

Defined (2)

The class is defined in the following location(s).

/vendor/calderawp/metaplate-core/vendor/xamin/handlebars.php/src/Handlebars/Autoloader.php  
  1. class Autoloader 
  2.  
  3. private $_baseDir; 
  4.  
  5. /** 
  6. * Autoloader constructor. 
  7. * @param string $baseDir Handlebars library base directory default is 
  8. * __DIR__.'/..' 
  9. */ 
  10. protected function __construct($baseDir = null) 
  11. if ($baseDir === null) { 
  12. $this->_baseDir = realpath(__DIR__ . '/..'); 
  13. } else { 
  14. $this->_baseDir = rtrim($baseDir, '/'); 
  15.  
  16. /** 
  17. * Register a new instance as an SPL autoloader. 
  18. * @param string $baseDir Handlebars library base directory, default is 
  19. * __DIR__.'/..' 
  20. * @return \Handlebars\Autoloader Registered Autoloader instance 
  21. */ 
  22. public static function register($baseDir = null) 
  23. $loader = new self($baseDir); 
  24. spl_autoload_register(array($loader, 'autoload')); 
  25.  
  26. return $loader; 
  27.  
  28. /** 
  29. * Autoload Handlebars classes. 
  30. * @param string $class class to load 
  31. * @return void 
  32. */ 
  33. public function autoload($class) 
  34. if ($class[0] !== '\\') { 
  35. $class = '\\' . $class; 
  36.  
  37. if (strpos($class, 'Handlebars') !== 1) { 
  38. return; 
  39.  
  40. $file = sprintf( 
  41. '%s%s.php',  
  42. $this->_baseDir,  
  43. str_replace('\\', '/', $class) 
  44. ); 
  45.  
  46. if (is_file($file)) { 
  47. include $file; 
  48.  
/vendor/xamin/handlebars.php/src/Handlebars/Autoloader.php  
  1. class Autoloader 
  2.  
  3. private $_baseDir; 
  4.  
  5. /** 
  6. * Autoloader constructor. 
  7. * @param string $baseDir Handlebars library base directory default is 
  8. * __DIR__.'/..' 
  9. */ 
  10. protected function __construct($baseDir = null) 
  11. if ($baseDir === null) { 
  12. $this->_baseDir = realpath(__DIR__ . '/..'); 
  13. } else { 
  14. $this->_baseDir = rtrim($baseDir, '/'); 
  15.  
  16. /** 
  17. * Register a new instance as an SPL autoloader. 
  18. * @param string $baseDir Handlebars library base directory, default is 
  19. * __DIR__.'/..' 
  20. * @return \Handlebars\Autoloader Registered Autoloader instance 
  21. */ 
  22. public static function register($baseDir = null) 
  23. $loader = new self($baseDir); 
  24. spl_autoload_register(array($loader, 'autoload')); 
  25.  
  26. return $loader; 
  27.  
  28. /** 
  29. * Autoload Handlebars classes. 
  30. * @param string $class class to load 
  31. * @return void 
  32. */ 
  33. public function autoload($class) 
  34. if ($class[0] !== '\\') { 
  35. $class = '\\' . $class; 
  36.  
  37. if (strpos($class, 'Handlebars') !== 1) { 
  38. return; 
  39.  
  40. $file = sprintf( 
  41. '%s%s.php',  
  42. $this->_baseDir,  
  43. str_replace('\\', '/', $class) 
  44. ); 
  45.  
  46. if (is_file($file)) { 
  47. include $file; 
  48.