Autoloader.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. @trigger_error('The "Twig_Extensions_Autoloader" class is deprecated since version 1.5. Use Composer instead.', E_USER_DEPRECATED);
  11. /**
  12. * Autoloads Twig Extensions classes.
  13. *
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. *
  16. * @deprecated since version 1.5, use Composer instead.
  17. */
  18. class Twig_Extensions_Autoloader
  19. {
  20. /**
  21. * Registers Twig_Extensions_Autoloader as an SPL autoloader.
  22. */
  23. public static function register()
  24. {
  25. spl_autoload_register(array(new self(), 'autoload'));
  26. }
  27. /**
  28. * Handles autoloading of classes.
  29. *
  30. * @param string $class a class name
  31. *
  32. * @return bool Returns true if the class has been loaded
  33. */
  34. public static function autoload($class)
  35. {
  36. if (0 !== strpos($class, 'Twig_Extensions')) {
  37. return;
  38. }
  39. if (file_exists($file = __DIR__.'/../../'.str_replace('_', '/', $class).'.php')) {
  40. require $file;
  41. }
  42. }
  43. }