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; |
19
|
|
|
|
20
|
|
|
use CuyZ\Notiz\Core\Definition\Tree\AbstractDefinitionComponent; |
21
|
|
|
use CuyZ\Notiz\Core\Notification\Settings\NotificationSettings; |
22
|
|
|
use CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail\Settings\View\View; |
23
|
|
|
use Romm\ConfigurationObject\Service\Items\DataPreProcessor\DataPreProcessor; |
24
|
|
|
use Romm\ConfigurationObject\Service\Items\DataPreProcessor\DataPreProcessorInterface; |
25
|
|
|
|
26
|
|
|
class EntityEmailSettings extends AbstractDefinitionComponent implements NotificationSettings, DataPreProcessorInterface |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @var string |
30
|
|
|
* |
31
|
|
|
* @validate NotEmpty |
32
|
|
|
*/ |
33
|
|
|
protected $defaultSender; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var \CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail\Settings\GlobalRecipients\GlobalRecipients |
37
|
|
|
*/ |
38
|
|
|
protected $globalRecipients; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var \CuyZ\Notiz\Domain\Notification\Email\Application\EntityEmail\Settings\View\View |
42
|
|
|
*/ |
43
|
|
|
protected $view; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
public function getDefaultSender(): string |
49
|
|
|
{ |
50
|
|
|
return $this->defaultSender; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @return GlobalRecipients\GlobalRecipients |
55
|
|
|
*/ |
56
|
|
|
public function getGlobalRecipients(): GlobalRecipients\GlobalRecipients |
57
|
|
|
{ |
58
|
|
|
return $this->globalRecipients; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return View |
63
|
|
|
*/ |
64
|
|
|
public function getView(): View |
65
|
|
|
{ |
66
|
|
|
return $this->view; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param DataPreProcessor $processor |
71
|
|
|
*/ |
72
|
|
|
public static function dataPreProcessor(DataPreProcessor $processor) |
73
|
|
|
{ |
74
|
|
|
$data = $processor->getData(); |
75
|
|
|
|
76
|
|
|
// View object must always be set. |
77
|
|
|
if (!is_array($data['view'])) { |
78
|
|
|
$data['view'] = []; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
// Recipients object must always be set. |
82
|
|
|
if (!is_array($data['globalRecipients'])) { |
83
|
|
|
$data['globalRecipients'] = []; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
$processor->setData($data); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|