TYPO3 API  SVNRelease
Preferences.php
Go to the documentation of this file.
00001 <?php
00002 
00003 /*
00004  * This file is part of SwiftMailer.
00005  * (c) 2004-2009 Chris Corbyn
00006  *
00007  * For the full copyright and license information, please view the LICENSE
00008  * file that was distributed with this source code.
00009  */
00010 
00011 //@require 'Swift/DependencyContainer.php';
00012 
00013 /**
00014  * Changes some global preference settings in Swift Mailer.
00015  * @package Swift
00016  * @author Chris Corbyn
00017  */
00018 class Swift_Preferences
00019 {
00020 
00021   /** Singleton instance */
00022   private static $_instance = null;
00023 
00024   /** Constructor not to be used */
00025   private function __construct() { }
00026 
00027   /**
00028    * Get a new instance of Preferences.
00029    * @return Swift_Preferences
00030    */
00031   public static function getInstance()
00032   {
00033     if (!isset(self::$_instance))
00034     {
00035       self::$_instance = new self();
00036     }
00037     return self::$_instance;
00038   }
00039 
00040   /**
00041    * Set the default charset used.
00042    * @param string
00043    * @return Swift_Preferences
00044    */
00045   public function setCharset($charset)
00046   {
00047     Swift_DependencyContainer::getInstance()
00048       ->register('properties.charset')->asValue($charset);
00049     return $this;
00050   }
00051 
00052   /**
00053    * Set the directory where temporary files can be saved.
00054    * @param string $dir
00055    * @return Swift_Preferences
00056    */
00057   public function setTempDir($dir)
00058   {
00059     Swift_DependencyContainer::getInstance()
00060       ->register('tempdir')->asValue($dir);
00061     return $this;
00062   }
00063 
00064   /**
00065    * Set the type of cache to use (i.e. "disk" or "array").
00066    * @param string $type
00067    * @return Swift_Preferences
00068    */
00069   public function setCacheType($type)
00070   {
00071     Swift_DependencyContainer::getInstance()
00072       ->register('cache')->asAliasOf(sprintf('cache.%s', $type));
00073     return $this;
00074   }
00075 
00076 }