/framework/vendor/swift/lib/classes/Swift/Preferences.php

http://zoop.googlecode.com/ · PHP · 76 lines · 32 code · 10 blank · 34 comment · 1 complexity · 55bf52c310769c66e9d9bcea1681cfe5 MD5 · raw file

  1. <?php
  2. /*
  3. * This file is part of SwiftMailer.
  4. * (c) 2004-2009 Chris Corbyn
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. //@require 'Swift/DependencyContainer.php';
  10. /**
  11. * Changes some global preference settings in Swift Mailer.
  12. * @package Swift
  13. * @author Chris Corbyn
  14. */
  15. class Swift_Preferences
  16. {
  17. /** Singleton instance */
  18. private static $_instance = null;
  19. /** Constructor not to be used */
  20. private function __construct() { }
  21. /**
  22. * Get a new instance of Preferences.
  23. * @return Swift_Preferences
  24. */
  25. public static function getInstance()
  26. {
  27. if (!isset(self::$_instance))
  28. {
  29. self::$_instance = new self();
  30. }
  31. return self::$_instance;
  32. }
  33. /**
  34. * Set the default charset used.
  35. * @param string
  36. * @return Swift_Preferences
  37. */
  38. public function setCharset($charset)
  39. {
  40. Swift_DependencyContainer::getInstance()
  41. ->register('properties.charset')->asValue($charset);
  42. return $this;
  43. }
  44. /**
  45. * Set the directory where temporary files can be saved.
  46. * @param string $dir
  47. * @return Swift_Preferences
  48. */
  49. public function setTempDir($dir)
  50. {
  51. Swift_DependencyContainer::getInstance()
  52. ->register('tempdir')->asValue($dir);
  53. return $this;
  54. }
  55. /**
  56. * Set the type of cache to use (i.e. "disk" or "array").
  57. * @param string $type
  58. * @return Swift_Preferences
  59. */
  60. public function setCacheType($type)
  61. {
  62. Swift_DependencyContainer::getInstance()
  63. ->register('cache')->asAliasOf(sprintf('cache.%s', $type));
  64. return $this;
  65. }
  66. }