|
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
|
|
|
* Changes some global preference settings in Swift Mailer. |
|
13
|
|
|
* |
|
14
|
|
|
* @author Chris Corbyn |
|
15
|
|
|
*/ |
|
16
|
|
|
class Swift_Preferences |
|
|
|
|
|
|
17
|
|
|
{ |
|
18
|
|
|
/** Singleton instance */ |
|
19
|
|
|
private static $_instance; |
|
20
|
|
|
|
|
21
|
|
|
/** Constructor not to be used */ |
|
22
|
|
|
private function __construct() |
|
23
|
|
|
{ |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Gets the instance of Preferences. |
|
28
|
|
|
* |
|
29
|
|
|
* @return self |
|
30
|
|
|
*/ |
|
31
|
123 |
|
public static function getInstance() |
|
32
|
|
|
{ |
|
33
|
123 |
|
if (!isset(self::$_instance)) { |
|
34
|
|
|
self::$_instance = new self(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
123 |
|
return self::$_instance; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Set the default charset used. |
|
42
|
|
|
* |
|
43
|
|
|
* @param string $charset |
|
44
|
|
|
* |
|
45
|
|
|
* @return $this |
|
46
|
|
|
*/ |
|
47
|
115 |
|
public function setCharset($charset) |
|
48
|
|
|
{ |
|
49
|
115 |
|
Swift_DependencyContainer::getInstance() |
|
50
|
115 |
|
->register('properties.charset') |
|
51
|
115 |
|
->asValue($charset); |
|
52
|
|
|
|
|
53
|
115 |
|
return $this; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Set the directory where temporary files can be saved. |
|
58
|
|
|
* |
|
59
|
|
|
* @param string $dir |
|
60
|
|
|
* |
|
61
|
|
|
* @return $this |
|
62
|
|
|
*/ |
|
63
|
|
|
public function setTempDir($dir) |
|
64
|
|
|
{ |
|
65
|
|
|
Swift_DependencyContainer::getInstance() |
|
66
|
|
|
->register('tempdir') |
|
67
|
|
|
->asValue($dir); |
|
68
|
|
|
|
|
69
|
|
|
return $this; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Set the type of cache to use (i.e. "disk" or "array"). |
|
74
|
|
|
* |
|
75
|
|
|
* @param string $type |
|
76
|
|
|
* |
|
77
|
|
|
* @return $this |
|
78
|
|
|
*/ |
|
79
|
|
|
public function setCacheType($type) |
|
80
|
|
|
{ |
|
81
|
|
|
Swift_DependencyContainer::getInstance() |
|
82
|
|
|
->register('cache') |
|
83
|
|
|
->asAliasOf(sprintf('cache.%s', $type)); |
|
84
|
|
|
|
|
85
|
|
|
return $this; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Set the QuotedPrintable dot escaper preference. |
|
90
|
|
|
* |
|
91
|
|
|
* @param bool $dotEscape |
|
92
|
|
|
* |
|
93
|
|
|
* @return $this |
|
94
|
|
|
*/ |
|
95
|
8 |
|
public function setQPDotEscape($dotEscape) |
|
96
|
|
|
{ |
|
97
|
8 |
|
$dotEscape = !empty($dotEscape); |
|
98
|
|
|
|
|
99
|
8 |
|
Swift_DependencyContainer::getInstance() |
|
100
|
8 |
|
->register('mime.qpcontentencoder') |
|
101
|
8 |
|
->asNewInstanceOf('Swift_Mime_ContentEncoder_QpContentEncoder') |
|
102
|
8 |
|
->withDependencies(array('mime.charstream', 'mime.bytecanonicalizer')) |
|
103
|
8 |
|
->addConstructorValue($dotEscape); |
|
104
|
|
|
|
|
105
|
8 |
|
return $this; |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.