You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Autoloader.php 1012B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) 2009 Fabien Potencier
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. /**
  11. * Autoloads Twig Extensions classes.
  12. *
  13. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  14. */
  15. class Twig_Extensions_Autoloader
  16. {
  17. /**
  18. * Registers Twig_Extensions_Autoloader as an SPL autoloader.
  19. */
  20. public static function register()
  21. {
  22. spl_autoload_register(array(new self(), 'autoload'));
  23. }
  24. /**
  25. * Handles autoloading of classes.
  26. *
  27. * @param string $class A class name.
  28. *
  29. * @return bool Returns true if the class has been loaded
  30. */
  31. public static function autoload($class)
  32. {
  33. if (0 !== strpos($class, 'Twig_Extensions')) {
  34. return;
  35. }
  36. if (file_exists($file = dirname(__FILE__).'/../../'.str_replace('_', '/', $class).'.php')) {
  37. require $file;
  38. }
  39. }
  40. }