1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of SwiftMailer. |
5
|
|
|
* (c) 2004-2009 Chris Corbyn |
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
|
|
|
/** |
12
|
|
|
* General utility class in Swift Mailer, not to be instantiated. |
13
|
|
|
* |
14
|
|
|
* |
15
|
|
|
* @author Chris Corbyn |
16
|
|
|
*/ |
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) |
33
|
|
|
{ |
34
|
|
|
self::$inits[] = $callable; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Internal autoloader for spl_autoload_register(). |
39
|
|
|
* |
40
|
|
|
* @param string $class |
41
|
|
|
*/ |
42
|
62 |
|
public static function autoload($class) |
43
|
|
|
{ |
44
|
|
|
// 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
|
|
|
spl_autoload_register(array('Swift', 'autoload')); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
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.