TYPO3  7.6
Swift.php
Go to the documentation of this file.
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 
17 abstract class Swift
18 {
20  const VERSION = '@SWIFT_VERSION_NUMBER@';
21 
22  public static $initialized = false;
23  public static $inits = array();
24 
33  public static function init($callable)
34  {
35  self::$inits[] = $callable;
36  }
37 
43  public static function autoload($class)
44  {
45  // Don't interfere with other autoloaders
46  if (0 !== strpos($class, 'Swift_')) {
47  return;
48  }
49 
50  $path = dirname(__FILE__).'/'.str_replace('_', '/', $class).'.php';
51 
52  if (!file_exists($path)) {
53  return;
54  }
55 
56  require $path;
57 
58  if (self::$inits && !self::$initialized) {
59  self::$initialized = true;
60  foreach (self::$inits as $init) {
61  call_user_func($init);
62  }
63  }
64  }
65 
73  public static function registerAutoload($callable = null)
74  {
75  if (null !== $callable) {
76  self::$inits[] = $callable;
77  }
78  spl_autoload_register(array('Swift', 'autoload'));
79  }
80 }