1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Copyright (C) 2017 |
5
|
|
|
* Nathan Boiron <[email protected]> |
6
|
|
|
* Romain Canon <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This file is part of the TYPO3 NotiZ project. |
9
|
|
|
* It is free software; you can redistribute it and/or modify it |
10
|
|
|
* under the terms of the GNU General Public License, either |
11
|
|
|
* version 3 of the License, or any later version. |
12
|
|
|
* |
13
|
|
|
* For the full copyright and license information, see: |
14
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail\Settings\View; |
18
|
|
|
|
19
|
|
|
use CuyZ\Notiz\Definition\Tree\AbstractDefinitionComponent; |
20
|
|
|
use CuyZ\Notiz\Exception\EntryNotFoundException; |
21
|
|
|
use Romm\ConfigurationObject\Service\Items\DataPreProcessor\DataPreProcessor; |
22
|
|
|
use Romm\ConfigurationObject\Service\Items\DataPreProcessor\DataPreProcessorInterface; |
23
|
|
|
|
24
|
|
|
class View extends AbstractDefinitionComponent implements DataPreProcessorInterface |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* @var \CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail\Settings\View\Layout[] |
28
|
|
|
*/ |
29
|
|
|
protected $layouts; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var array |
33
|
|
|
*/ |
34
|
|
|
protected $layoutRootPaths; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var array |
38
|
|
|
*/ |
39
|
|
|
protected $templateRootPaths; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var array |
43
|
|
|
*/ |
44
|
|
|
protected $partialRootPaths; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @return Layout[] |
48
|
|
|
*/ |
49
|
|
|
public function getLayouts() |
50
|
|
|
{ |
51
|
|
|
return $this->layouts; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param string $identifier |
56
|
|
|
* @return bool |
57
|
|
|
*/ |
58
|
|
|
public function hasLayout($identifier) |
59
|
|
|
{ |
60
|
|
|
return true === isset($this->layouts[$identifier]); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param string $identifier |
65
|
|
|
* @return Layout |
66
|
|
|
* |
67
|
|
|
* @throws EntryNotFoundException |
68
|
|
|
*/ |
69
|
|
|
public function getLayout($identifier) |
70
|
|
|
{ |
71
|
|
|
if (false === $this->hasLayout($identifier)) { |
72
|
|
|
throw EntryNotFoundException::entityEmailViewLayoutNotFound($identifier); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
return $this->layouts[$identifier]; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return array |
80
|
|
|
*/ |
81
|
|
|
public function getLayoutRootPaths() |
82
|
|
|
{ |
83
|
|
|
return $this->layoutRootPaths; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return array |
88
|
|
|
*/ |
89
|
|
|
public function getTemplateRootPaths() |
90
|
|
|
{ |
91
|
|
|
return $this->templateRootPaths; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return array |
96
|
|
|
*/ |
97
|
|
|
public function getPartialRootPaths() |
98
|
|
|
{ |
99
|
|
|
return $this->partialRootPaths; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Method called during the definition object construction: it allows |
104
|
|
|
* manipulating the data array before it is actually used to construct the |
105
|
|
|
* object. |
106
|
|
|
* |
107
|
|
|
* We use it to automatically fill the `identifier` property of the layouts |
108
|
|
|
* with the keys of the array. |
109
|
|
|
* |
110
|
|
|
* @param DataPreProcessor $processor |
111
|
|
|
*/ |
112
|
|
|
public static function dataPreProcessor(DataPreProcessor $processor) |
113
|
|
|
{ |
114
|
|
|
self::forceIdentifierForProperty($processor, 'layouts'); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|