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