ClassLoader.php 910 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Swift Mailer Class Loader for includes
  4. * Please read the LICENSE file
  5. * @author Chris Corbyn <chris@w3style.co.uk>
  6. * @package Swift
  7. * @license GNU Lesser General Public License
  8. */
  9. if (!defined("SWIFT_ABS_PATH")) define("SWIFT_ABS_PATH", dirname(__FILE__) . "/..");
  10. /**
  11. * Locates and includes class files
  12. * @package Swift
  13. * @author Chris Corbyn <chris@w3style.co.uk>
  14. */
  15. class Swift_ClassLoader
  16. {
  17. /**
  18. * A list of files already located
  19. * @var array
  20. */
  21. protected static $located = array();
  22. /**
  23. * Load a new class into memory
  24. * @param string The name of the class, case SenSItivE
  25. */
  26. public static function load($name)
  27. {
  28. if (in_array($name, self::$located) || class_exists($name, false) || interface_exists($name, false))
  29. return;
  30. require_once SWIFT_ABS_PATH . "/" . str_replace("_", "/", $name) . ".php";
  31. self::$located[] = $name;
  32. }
  33. }