4 * This file is part of SwiftMailer.
5 * (c) 2004-2009 Chris Corbyn
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 //@require 'Swift/DependencyContainer.php';
14 * Changes some global preference settings in Swift Mailer.
16 * @author Chris Corbyn
18 class Swift_Preferences
21 /** Singleton instance */
22 private static $_instance = null;
24 /** Constructor not to be used */
25 private function __construct() { }
28 * Get a new instance of Preferences.
29 * @return Swift_Preferences
31 public static function getInstance()
33 if (!isset(self
::$_instance))
35 self
::$_instance = new self();
37 return self
::$_instance;
41 * Set the default charset used.
43 * @return Swift_Preferences
45 public function setCharset($charset)
47 Swift_DependencyContainer
::getInstance()
48 ->register('properties.charset')->asValue($charset);
53 * Set the directory where temporary files can be saved.
55 * @return Swift_Preferences
57 public function setTempDir($dir)
59 Swift_DependencyContainer
::getInstance()
60 ->register('tempdir')->asValue($dir);
65 * Set the type of cache to use (i.e. "disk" or "array").
67 * @return Swift_Preferences
69 public function setCacheType($type)
71 Swift_DependencyContainer
::getInstance()
72 ->register('cache')->asAliasOf(sprintf('cache.%s', $type));