1 | <?php |
||
17 | abstract class Swift |
||
|
|||
18 | { |
||
19 | const VERSION = '5.x'; |
||
20 | |||
21 | public static $initialized = false; |
||
22 | public static $inits = array(); |
||
23 | |||
24 | /** |
||
25 | * Registers an initializer callable that will be called the first time |
||
26 | * a SwiftMailer class is autoloaded. |
||
27 | * |
||
28 | * This enables you to tweak the default configuration in a lazy way. |
||
29 | * |
||
30 | * @param mixed $callable A valid PHP callable that will be called when autoloading the first Swift class |
||
31 | */ |
||
32 | public static function init($callable) |
||
36 | |||
37 | /** |
||
38 | * Internal autoloader for spl_autoload_register(). |
||
39 | * |
||
40 | * @param string $class |
||
41 | */ |
||
42 | 62 | public static function autoload($class) |
|
43 | { |
||
44 | // "maybe" don't interfere with other autoloaders |
||
45 | 62 | if (0 !== strpos($class, 'Swift_')) { |
|
46 | return; |
||
47 | } |
||
48 | |||
49 | 62 | $path = __DIR__ . '/' . str_replace('_', '/', $class) . '.php'; |
|
50 | |||
51 | 62 | if (!file_exists($path)) { |
|
52 | return; |
||
53 | } |
||
54 | |||
55 | 62 | require $path; |
|
56 | |||
57 | 62 | if (self::$inits && !self::$initialized) { |
|
58 | self::$initialized = true; |
||
59 | foreach (self::$inits as $init) { |
||
60 | call_user_func($init); |
||
61 | } |
||
62 | } |
||
63 | 62 | } |
|
64 | |||
65 | /** |
||
66 | * Configure autoloading using Swift Mailer. |
||
67 | * |
||
68 | * This is designed to play nicely with other autoloaders. |
||
69 | * |
||
70 | * @param mixed $callable A valid PHP callable that will be called when autoloading the first Swift class |
||
71 | */ |
||
72 | public static function registerAutoload($callable = null) |
||
73 | { |
||
74 | if (null !== $callable) { |
||
75 | self::$inits[] = $callable; |
||
76 | } |
||
77 | |||
78 | spl_autoload_register(array('Swift', 'autoload')); |
||
79 | } |
||
80 | |||
81 | /** |
||
82 | * php-strtolower with static-cache |
||
83 | * |
||
84 | * @param $string |
||
85 | * |
||
86 | * @return mixed |
||
87 | */ |
||
88 | 273 | public static function strtolowerWithStaticCache($string) |
|
100 | } |
||
101 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.