|
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\Event\Scheduler; |
|
18
|
|
|
|
|
19
|
|
|
use CuyZ\Notiz\Core\Event\AbstractEvent; |
|
20
|
|
|
use CuyZ\Notiz\Core\Event\Support\HasNotificationData; |
|
21
|
|
|
use CuyZ\Notiz\Core\Event\Support\ProvidesExampleProperties; |
|
22
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
23
|
|
|
use TYPO3\CMS\Scheduler\Task\AbstractTask; |
|
24
|
|
|
|
|
25
|
|
|
abstract class SchedulerTaskEvent extends AbstractEvent implements ProvidesExampleProperties |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @marker |
|
29
|
|
|
* |
|
30
|
|
|
* @var int |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $uid; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @marker |
|
36
|
|
|
* |
|
37
|
|
|
* @var string |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $title; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @marker |
|
43
|
|
|
* |
|
44
|
|
|
* @var string |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $description; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @marker |
|
50
|
|
|
* @label Event/Scheduler/SchedulerTask:marker.data |
|
51
|
|
|
* |
|
52
|
|
|
* @var array |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $data; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param AbstractTask $task |
|
58
|
|
|
*/ |
|
59
|
|
|
protected function checkTaskFilter(AbstractTask $task) |
|
60
|
|
|
{ |
|
61
|
|
|
if ($this->configuration['doFilterTasks']) { |
|
62
|
|
|
$allowedTasks = GeneralUtility::trimExplode(',', $this->configuration['filteredTasks']); |
|
63
|
|
|
|
|
64
|
|
|
if (!in_array($task->getTaskUid(), $allowedTasks)) { |
|
65
|
|
|
$this->cancelDispatch(); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @param AbstractTask $task |
|
72
|
|
|
*/ |
|
73
|
|
|
protected function fillTaskData(AbstractTask $task) |
|
74
|
|
|
{ |
|
75
|
|
|
$this->uid = $task->getTaskUid(); |
|
76
|
|
|
$this->title = $task->getTaskTitle(); |
|
77
|
|
|
$this->description = $task->getDescription(); |
|
78
|
|
|
|
|
79
|
|
|
if ($task instanceof HasNotificationData) { |
|
80
|
|
|
$this->data = $task->getNotificationData(); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return array |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getExampleProperties() |
|
88
|
|
|
{ |
|
89
|
|
|
return [ |
|
90
|
|
|
'uid' => '42', |
|
91
|
|
|
'title' => 'My Scheduler Task', |
|
92
|
|
|
'description' => 'Some random description that gives details about my scheduler task.', |
|
93
|
|
|
'data' => ['foo' => 'bar'], |
|
94
|
|
|
]; |
|
95
|
|
|
} |
|
96
|
|
|
} |
|
97
|
|
|
|