|
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
|
|
|
|
|
8
|
|
|
namespace ZBateson\MailMimeParser\Parser; |
|
9
|
|
|
|
|
10
|
|
|
use ZBateson\MailMimeParser\Parser\Proxy\ParserPartProxyFactory; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Provides basic implementations for: |
|
14
|
|
|
* - IParser::setParserManager |
|
15
|
|
|
* - IParser::getParserMessageProxyFactory (returns $this->parserMessageProxyFactory |
|
16
|
|
|
* which can be set via the default constructor) |
|
17
|
|
|
* - IParser::getParserPartProxyFactory (returns $this->parserPartProxyFactory |
|
18
|
|
|
* which can be set via the default constructor) |
|
19
|
|
|
* |
|
20
|
|
|
* @author Zaahid Bateson |
|
21
|
|
|
*/ |
|
22
|
|
|
abstract class AbstractParserService implements IParserService |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* @var ParserPartProxyFactory the parser's message proxy factory service |
|
26
|
|
|
* responsible for creating an IMessage part wrapped in a |
|
27
|
|
|
* ParserPartProxy. |
|
28
|
|
|
*/ |
|
29
|
|
|
protected ParserPartProxyFactory $parserMessageProxyFactory; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var ParserPartProxyFactory the parser's part proxy factory service |
|
33
|
|
|
* responsible for creating IMessagePart parts wrapped in a |
|
34
|
|
|
* ParserPartProxy. |
|
35
|
|
|
*/ |
|
36
|
|
|
protected ParserPartProxyFactory $parserPartProxyFactory; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var PartBuilderFactory Service for creating PartBuilder objects for new |
|
40
|
|
|
* children. |
|
41
|
|
|
*/ |
|
42
|
|
|
protected PartBuilderFactory $partBuilderFactory; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var ParserManagerService the ParserManager, which should call setParserManager |
|
46
|
|
|
* when the parser is added. |
|
47
|
|
|
*/ |
|
48
|
|
|
protected ParserManagerService $parserManager; |
|
49
|
|
|
|
|
50
|
21 |
|
public function __construct( |
|
51
|
|
|
ParserPartProxyFactory $parserMessageProxyFactory, |
|
52
|
|
|
ParserPartProxyFactory $parserPartProxyFactory, |
|
53
|
|
|
PartBuilderFactory $partBuilderFactory |
|
54
|
|
|
) { |
|
55
|
21 |
|
$this->parserMessageProxyFactory = $parserMessageProxyFactory; |
|
56
|
21 |
|
$this->parserPartProxyFactory = $parserPartProxyFactory; |
|
57
|
21 |
|
$this->partBuilderFactory = $partBuilderFactory; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
21 |
|
public function setParserManager(ParserManagerService $pm) : static |
|
61
|
|
|
{ |
|
62
|
21 |
|
$this->parserManager = $pm; |
|
63
|
21 |
|
return $this; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
107 |
|
public function getParserMessageProxyFactory() : ParserPartProxyFactory |
|
67
|
|
|
{ |
|
68
|
107 |
|
return $this->parserMessageProxyFactory; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
76 |
|
public function getParserPartProxyFactory() : ParserPartProxyFactory |
|
72
|
|
|
{ |
|
73
|
76 |
|
return $this->parserPartProxyFactory; |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|