CacheFactory.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Swift Mailer Cache Factory class
  4. * Please read the LICENSE file
  5. * @author Chris Corbyn <chris@w3style.co.uk>
  6. * @package Swift_Cache
  7. * @license GNU Lesser General Public License
  8. */
  9. require_once dirname(__FILE__) . "/ClassLoader.php";
  10. /**
  11. * Makes instances of the cache the user has defined
  12. * @package Swift_Cache
  13. * @author Chris Corbyn <chris@w3style.co.uk>
  14. */
  15. class Swift_CacheFactory
  16. {
  17. /**
  18. * The name of the class which defines the cache
  19. * @var string Case SenSITivE
  20. */
  21. protected static $className = "Swift_Cache_Memory";
  22. /**
  23. * Set the name of the class which is supposed to be used
  24. * This also includes the file
  25. * @param string The class name
  26. */
  27. public static function setClassName($name)
  28. {
  29. Swift_ClassLoader::load($name);
  30. self::$className = $name;
  31. }
  32. /**
  33. * Return a new instance of the cache object
  34. * @return Swift_Cache
  35. */
  36. public static function getCache()
  37. {
  38. $className = self::$className;
  39. Swift_ClassLoader::load($className);
  40. $instance = new $className();
  41. return $instance;
  42. }
  43. }