diff -r 6d109e3804ac -r 9a001a04b634 Twig-1.3.0/lib/Twig/Autoloader.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Twig-1.3.0/lib/Twig/Autoloader.php Tue Oct 25 23:56:28 2011 +0200 @@ -0,0 +1,46 @@ + + */ +class Twig_Autoloader +{ + /** + * Registers Twig_Autoloader as an SPL autoloader. + */ + static public function register() + { + ini_set('unserialize_callback_func', 'spl_autoload_call'); + spl_autoload_register(array(new self, 'autoload')); + } + + /** + * Handles autoloading of classes. + * + * @param string $class A class name. + * + * @return boolean Returns true if the class has been loaded + */ + static public function autoload($class) + { + if (0 !== strpos($class, 'Twig')) { + return; + } + + if (is_file($file = dirname(__FILE__).'/../'.str_replace(array('_', "\0"), array('/', ''), $class).'.php')) { + require $file; + } + } +}