vendor/swiftmailer/lib/classes/Swift/Preferences.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     1 <?php
       
     2 
       
     3 /*
       
     4  * This file is part of SwiftMailer.
       
     5  * (c) 2004-2009 Chris Corbyn
       
     6  *
       
     7  * For the full copyright and license information, please view the LICENSE
       
     8  * file that was distributed with this source code.
       
     9  */
       
    10 
       
    11 
       
    12 /**
       
    13  * Changes some global preference settings in Swift Mailer.
       
    14  * @package Swift
       
    15  * @author Chris Corbyn
       
    16  */
       
    17 class Swift_Preferences
       
    18 {
       
    19   
       
    20   /** Singleton instance */
       
    21   private static $_instance = null;
       
    22   
       
    23   /** Constructor not to be used */
       
    24   private function __construct() { }
       
    25   
       
    26   /**
       
    27    * Get a new instance of Preferences.
       
    28    * @return Swift_Preferences
       
    29    */
       
    30   public static function getInstance()
       
    31   {
       
    32     if (!isset(self::$_instance))
       
    33     {
       
    34       self::$_instance = new self();
       
    35     }
       
    36     return self::$_instance;
       
    37   }
       
    38   
       
    39   /**
       
    40    * Set the default charset used.
       
    41    * @param string
       
    42    * @return Swift_Preferences
       
    43    */
       
    44   public function setCharset($charset)
       
    45   {
       
    46     Swift_DependencyContainer::getInstance()
       
    47       ->register('properties.charset')->asValue($charset);
       
    48     return $this;
       
    49   }
       
    50   
       
    51   /**
       
    52    * Set the directory where temporary files can be saved.
       
    53    * @param string $dir
       
    54    * @return Swift_Preferences
       
    55    */
       
    56   public function setTempDir($dir)
       
    57   {
       
    58     Swift_DependencyContainer::getInstance()
       
    59       ->register('tempdir')->asValue($dir);
       
    60     return $this;
       
    61   }
       
    62   
       
    63   /**
       
    64    * Set the type of cache to use (i.e. "disk" or "array").
       
    65    * @param string $type
       
    66    * @return Swift_Preferences
       
    67    */
       
    68   public function setCacheType($type)
       
    69   {
       
    70     Swift_DependencyContainer::getInstance()
       
    71       ->register('cache')->asAliasOf(sprintf('cache.%s', $type));
       
    72     return $this;
       
    73   }
       
    74   
       
    75   /**
       
    76    * Add the
       
    77    * @param boolean $dotEscape
       
    78    */
       
    79   public function setQPDotEscape($dotEscape)
       
    80   {
       
    81     $dotEscape=!empty($dotEscape);
       
    82     Swift_DependencyContainer::getInstance()
       
    83       -> register('mime.qpcontentencoder')
       
    84       -> asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder')
       
    85       -> withDependencies(array('mime.charstream', 'mime.bytecanonicalizer'))
       
    86       -> addConstructorValue($dotEscape);
       
    87     return $this;
       
    88   }
       
    89   
       
    90 }