dolibarr/htdocs/includes/swiftmailer/lib/classes/Swift/Preferences.php

101 lines
2.2 KiB
PHP
Raw Normal View History

2016-04-16 18:15:03 +02:00
<?php
/*
* This file is part of SwiftMailer.
* (c) 2004-2009 Chris Corbyn
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
* Changes some global preference settings in Swift Mailer.
*
* @author Chris Corbyn
*/
class Swift_Preferences
{
/** Singleton instance */
2018-01-21 15:55:56 +01:00
private static $instance = null;
2016-04-16 18:15:03 +02:00
/** Constructor not to be used */
private function __construct()
{
}
/**
* Gets the instance of Preferences.
*
2018-01-21 15:55:56 +01:00
* @return self
2016-04-16 18:15:03 +02:00
*/
public static function getInstance()
{
2018-01-21 15:55:56 +01:00
if (!isset(self::$instance)) {
self::$instance = new self();
2016-04-16 18:15:03 +02:00
}
2018-01-21 15:55:56 +01:00
return self::$instance;
2016-04-16 18:15:03 +02:00
}
/**
* Set the default charset used.
*
* @param string $charset
*
2018-01-21 15:55:56 +01:00
* @return $this
2016-04-16 18:15:03 +02:00
*/
public function setCharset($charset)
{
2018-01-21 15:55:56 +01:00
Swift_DependencyContainer::getInstance()->register('properties.charset')->asValue($charset);
2016-04-16 18:15:03 +02:00
return $this;
}
/**
* Set the directory where temporary files can be saved.
*
* @param string $dir
*
2018-01-21 15:55:56 +01:00
* @return $this
2016-04-16 18:15:03 +02:00
*/
public function setTempDir($dir)
{
2018-01-21 15:55:56 +01:00
Swift_DependencyContainer::getInstance()->register('tempdir')->asValue($dir);
2016-04-16 18:15:03 +02:00
return $this;
}
/**
* Set the type of cache to use (i.e. "disk" or "array").
*
* @param string $type
*
2018-01-21 15:55:56 +01:00
* @return $this
2016-04-16 18:15:03 +02:00
*/
public function setCacheType($type)
{
2018-01-21 15:55:56 +01:00
Swift_DependencyContainer::getInstance()->register('cache')->asAliasOf(sprintf('cache.%s', $type));
2016-04-16 18:15:03 +02:00
return $this;
}
/**
* Set the QuotedPrintable dot escaper preference.
*
* @param bool $dotEscape
*
2018-01-21 15:55:56 +01:00
* @return $this
2016-04-16 18:15:03 +02:00
*/
public function setQPDotEscape($dotEscape)
{
$dotEscape = !empty($dotEscape);
Swift_DependencyContainer::getInstance()
->register('mime.qpcontentencoder')
->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder')
2021-12-07 17:11:34 +01:00
->withDependencies(['mime.charstream', 'mime.bytecanonicalizer'])
2016-04-16 18:15:03 +02:00
->addConstructorValue($dotEscape);
return $this;
}
}