1<?php 2 3/* 4 * This file is part of Twig. 5 * 6 * (c) Fabien Potencier 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12@trigger_error('The Twig_Autoloader class is deprecated since version 1.21 and will be removed in 2.0. Use Composer instead.', E_USER_DEPRECATED); 13 14/** 15 * Autoloads Twig classes. 16 * 17 * @author Fabien Potencier <fabien@symfony.com> 18 * 19 * @deprecated since 1.21 and will be removed in 2.0. Use Composer instead. 2.0. 20 */ 21class Twig_Autoloader 22{ 23 /** 24 * Registers Twig_Autoloader as an SPL autoloader. 25 * 26 * @param bool $prepend whether to prepend the autoloader or not 27 */ 28 public static function register($prepend = false) 29 { 30 @trigger_error('Using Twig_Autoloader is deprecated since version 1.21. Use Composer instead.', E_USER_DEPRECATED); 31 32 spl_autoload_register([__CLASS__, 'autoload'], true, $prepend); 33 } 34 35 /** 36 * Handles autoloading of classes. 37 * 38 * @param string $class a class name 39 */ 40 public static function autoload($class) 41 { 42 if (0 !== strpos($class, 'Twig')) { 43 return; 44 } 45 46 if (is_file($file = __DIR__.'/../'.str_replace(['_', "\0"], ['/', ''], $class).'.php')) { 47 require $file; 48 } elseif (is_file($file = __DIR__.'/../../src/'.str_replace(['Twig\\', '\\', "\0"], ['', '/', ''], $class).'.php')) { 49 require $file; 50 } 51 } 52} 53