|
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 * @package Swift |
|
15 * |
|
16 * @author Chris Corbyn |
|
17 */ |
|
18 abstract class Swift |
|
19 { |
|
20 |
|
21 static $initialized = false; |
|
22 static $initPath; |
|
23 |
|
24 /** Swift Mailer Version number generated during dist release process */ |
|
25 const VERSION = '@SWIFT_VERSION_NUMBER@'; |
|
26 |
|
27 /** |
|
28 * Internal autoloader for spl_autoload_register(). |
|
29 * |
|
30 * @param string $class |
|
31 */ |
|
32 public static function autoload($class) |
|
33 { |
|
34 //Don't interfere with other autoloaders |
|
35 if (0 !== strpos($class, 'Swift_')) |
|
36 { |
|
37 return; |
|
38 } |
|
39 |
|
40 $path = dirname(__FILE__).'/'.str_replace('_', '/', $class).'.php'; |
|
41 |
|
42 if (!file_exists($path)) |
|
43 { |
|
44 return; |
|
45 } |
|
46 |
|
47 if (self::$initPath && !self::$initialized) |
|
48 { |
|
49 self::$initialized = true; |
|
50 require self::$initPath; |
|
51 } |
|
52 |
|
53 require_once $path; |
|
54 } |
|
55 |
|
56 /** |
|
57 * Configure autoloading using Swift Mailer. |
|
58 * |
|
59 * This is designed to play nicely with other autoloaders. |
|
60 * |
|
61 * @param string $initPath The init script to load when autoloading the first Swift class |
|
62 */ |
|
63 public static function registerAutoload($initPath = null) |
|
64 { |
|
65 self::$initPath = $initPath; |
|
66 spl_autoload_register(array('Swift', 'autoload')); |
|
67 } |
|
68 |
|
69 } |