Preferences.php 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. /**
  10. * Changes some global preference settings in Swift Mailer.
  11. * @package Swift
  12. * @author Chris Corbyn
  13. */
  14. class Swift_Preferences
  15. {
  16. /** Singleton instance */
  17. private static $_instance = null;
  18. /** Constructor not to be used */
  19. private function __construct() { }
  20. /**
  21. * Get a new instance of Preferences.
  22. * @return Swift_Preferences
  23. */
  24. public static function getInstance()
  25. {
  26. if (!isset(self::$_instance))
  27. {
  28. self::$_instance = new self();
  29. }
  30. return self::$_instance;
  31. }
  32. /**
  33. * Set the default charset used.
  34. * @param string
  35. * @return Swift_Preferences
  36. */
  37. public function setCharset($charset)
  38. {
  39. Swift_DependencyContainer::getInstance()
  40. ->register('properties.charset')->asValue($charset);
  41. return $this;
  42. }
  43. /**
  44. * Set the directory where temporary files can be saved.
  45. * @param string $dir
  46. * @return Swift_Preferences
  47. */
  48. public function setTempDir($dir)
  49. {
  50. Swift_DependencyContainer::getInstance()
  51. ->register('tempdir')->asValue($dir);
  52. return $this;
  53. }
  54. /**
  55. * Set the type of cache to use (i.e. "disk" or "array").
  56. * @param string $type
  57. * @return Swift_Preferences
  58. */
  59. public function setCacheType($type)
  60. {
  61. Swift_DependencyContainer::getInstance()
  62. ->register('cache')->asAliasOf(sprintf('cache.%s', $type));
  63. return $this;
  64. }
  65. /**
  66. * Add the
  67. * @param boolean $dotEscape
  68. */
  69. public function setQPDotEscape($dotEscape)
  70. {
  71. $dotEscape=!empty($dotEscape);
  72. Swift_DependencyContainer::getInstance()
  73. -> register('mime.qpcontentencoder')
  74. -> asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder')
  75. -> withDependencies(array('mime.charstream', 'mime.bytecanonicalizer'))
  76. -> addConstructorValue($dotEscape);
  77. return $this;
  78. }
  79. }