|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the ZBateson\MailMimeParser project. |
|
4
|
|
|
* |
|
5
|
|
|
* @license http://opensource.org/licenses/bsd-license.php BSD |
|
6
|
|
|
*/ |
|
7
|
|
|
namespace ZBateson\MailMimeParser\Message\Helper; |
|
8
|
|
|
|
|
9
|
|
|
use ZBateson\MailMimeParser\Message\Part\Factory\PartBuilderFactory; |
|
10
|
|
|
use ZBateson\MailMimeParser\Message\Part\Factory\PartFactoryService; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Responsible for creating helper singletons. |
|
14
|
|
|
* |
|
15
|
|
|
* @author Zaahid Bateson |
|
16
|
|
|
*/ |
|
17
|
|
|
class MessageHelperService |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var PartBuilderFactory |
|
21
|
|
|
*/ |
|
22
|
|
|
private $partBuilderFactory; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var GenericHelper the GenericHelper singleton |
|
26
|
|
|
*/ |
|
27
|
|
|
private $genericHelper; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var MultipartHelper the MultipartHelper singleton |
|
31
|
|
|
*/ |
|
32
|
|
|
private $multipartHelper; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var PrivacyHelper the PrivacyHelper singleton |
|
36
|
|
|
*/ |
|
37
|
|
|
private $privacyHelper; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var PartFactoryService the PartFactoryService |
|
41
|
|
|
*/ |
|
42
|
|
|
private $partFactoryService; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @param PartBuilderFactory $partBuilderFactory |
|
46
|
|
|
*/ |
|
47
|
|
|
public function __construct(PartBuilderFactory $partBuilderFactory) |
|
48
|
|
|
{ |
|
49
|
|
|
$this->partBuilderFactory = $partBuilderFactory; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Set separately to avoid circular dependencies (PartFactoryService needs a |
|
54
|
|
|
* MessageHelperService). |
|
55
|
|
|
* |
|
56
|
|
|
* @param PartFactoryService $partFactoryService |
|
57
|
|
|
*/ |
|
58
|
|
|
public function setPartFactoryService(PartFactoryService $partFactoryService) |
|
59
|
|
|
{ |
|
60
|
|
|
$this->partFactoryService = $partFactoryService; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Returns the GenericHelper singleton |
|
65
|
|
|
* |
|
66
|
|
|
* @return GenericHelper |
|
67
|
|
|
*/ |
|
68
|
|
|
public function getGenericHelper() |
|
69
|
|
|
{ |
|
70
|
|
|
if ($this->genericHelper === null) { |
|
71
|
|
|
$this->genericHelper = new GenericHelper( |
|
72
|
|
|
$this->partFactoryService->getMimePartFactory(), |
|
73
|
|
|
$this->partFactoryService->getUUEncodedPartFactory(), |
|
74
|
|
|
$this->partBuilderFactory |
|
75
|
|
|
); |
|
76
|
|
|
} |
|
77
|
|
|
return $this->genericHelper; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Returns the MultipartHelper singleton |
|
82
|
|
|
* |
|
83
|
|
|
* @return MultipartHelper |
|
84
|
|
|
*/ |
|
85
|
|
|
public function getMultipartHelper() |
|
86
|
|
|
{ |
|
87
|
|
|
if ($this->multipartHelper === null) { |
|
88
|
|
|
$this->multipartHelper = new MultipartHelper( |
|
89
|
|
|
$this->partFactoryService->getMimePartFactory(), |
|
90
|
|
|
$this->partFactoryService->getUUEncodedPartFactory(), |
|
91
|
|
|
$this->partBuilderFactory, |
|
92
|
|
|
$this->getGenericHelper() |
|
93
|
|
|
); |
|
94
|
|
|
} |
|
95
|
|
|
return $this->multipartHelper; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Returns the PrivacyHelper singleton |
|
100
|
|
|
* |
|
101
|
|
|
* @return PrivacyHelper |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getPrivacyHelper() |
|
104
|
|
|
{ |
|
105
|
|
|
if ($this->privacyHelper === null) { |
|
106
|
|
|
$this->privacyHelper = new PrivacyHelper( |
|
107
|
|
|
$this->partFactoryService->getMimePartFactory(), |
|
108
|
|
|
$this->partFactoryService->getUUEncodedPartFactory(), |
|
109
|
|
|
$this->partBuilderFactory, |
|
110
|
|
|
$this->getGenericHelper(), |
|
111
|
|
|
$this->getMultipartHelper() |
|
112
|
|
|
); |
|
113
|
|
|
} |
|
114
|
|
|
return $this->privacyHelper; |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|