1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Copyright (C) 2018 |
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; |
18
|
|
|
|
19
|
|
|
use CuyZ\Notiz\Core\Definition\DefinitionService; |
20
|
|
|
use CuyZ\Notiz\Core\Definition\Tree\Definition; |
21
|
|
|
use CuyZ\Notiz\Core\Definition\Tree\Notification\Channel\ChannelDefinition; |
22
|
|
|
use CuyZ\Notiz\Core\Definition\Tree\Notification\NotificationDefinition; |
23
|
|
|
use CuyZ\Notiz\Core\Notification\MultipleChannelsNotification; |
24
|
|
|
use CuyZ\Notiz\Core\Notification\Notification; |
25
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
26
|
|
|
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; |
27
|
|
|
use TYPO3\CMS\Extbase\Service\FlexFormService; |
28
|
|
|
|
29
|
|
|
abstract class EntityNotification extends AbstractEntity implements Notification, MultipleChannelsNotification |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $title; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var string |
38
|
|
|
*/ |
39
|
|
|
protected $event; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
protected $channel; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var string |
48
|
|
|
*/ |
49
|
|
|
protected $eventConfigurationFlex; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var array |
53
|
|
|
*/ |
54
|
|
|
protected $eventConfiguration; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
public function getTitle() |
60
|
|
|
{ |
61
|
|
|
return $this->title; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param string $title |
66
|
|
|
*/ |
67
|
|
|
public function setTitle($title) |
68
|
|
|
{ |
69
|
|
|
$this->title = $title; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return string |
74
|
|
|
*/ |
75
|
|
|
public function getEvent() |
76
|
|
|
{ |
77
|
|
|
return $this->event; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @param string $event |
82
|
|
|
*/ |
83
|
|
|
public function setEvent($event) |
84
|
|
|
{ |
85
|
|
|
$this->event = $event; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return string |
90
|
|
|
*/ |
91
|
|
|
public function getChannel() |
92
|
|
|
{ |
93
|
|
|
return $this->channel; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @param string $channel |
98
|
|
|
*/ |
99
|
|
|
public function setChannel($channel) |
100
|
|
|
{ |
101
|
|
|
$this->channel = $channel; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param string $eventConfigurationFlex |
106
|
|
|
*/ |
107
|
|
|
public function setEventConfigurationFlex($eventConfigurationFlex) |
108
|
|
|
{ |
109
|
|
|
$this->eventConfigurationFlex = $eventConfigurationFlex; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @return NotificationDefinition |
114
|
|
|
*/ |
115
|
|
|
public function getNotificationDefinition() |
116
|
|
|
{ |
117
|
|
|
return $this->getDefinition()->getNotification(static::getDefinitionIdentifier()); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* Returns the event configuration stored as a FlexForm string. |
122
|
|
|
* |
123
|
|
|
* @return array |
124
|
|
|
*/ |
125
|
|
|
public function getEventConfiguration() |
126
|
|
|
{ |
127
|
|
|
if (null === $this->eventConfiguration) { |
128
|
|
|
/** @var FlexFormService $flexFormService */ |
129
|
|
|
$flexFormService = GeneralUtility::makeInstance(FlexFormService::class); |
130
|
|
|
|
131
|
|
|
$this->eventConfiguration = $flexFormService->convertFlexFormContentToArray($this->eventConfigurationFlex); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
return $this->eventConfiguration; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* The selected channel is stored in the `$channel` property. |
139
|
|
|
* |
140
|
|
|
* @inheritdoc |
141
|
|
|
*/ |
142
|
|
|
public function shouldDispatch(ChannelDefinition $definition) |
143
|
|
|
{ |
144
|
|
|
return $definition->getClassName() === $this->getChannel(); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* @return string |
149
|
|
|
*/ |
150
|
|
|
abstract public static function getDefinitionIdentifier(); |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @return Definition |
154
|
|
|
*/ |
155
|
|
|
protected function getDefinition() |
156
|
|
|
{ |
157
|
|
|
return DefinitionService::get()->getDefinition(); |
158
|
|
|
} |
159
|
|
|
} |
160
|
|
|
|