Issues (186)

Domain/Event/Scheduler/SchedulerTaskEvent.php (1 issue)

Labels
Severity
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\Event\Scheduler;
19
20
use CuyZ\Notiz\Core\Event\AbstractEvent;
21
use CuyZ\Notiz\Core\Event\Support\HasNotificationData;
22
use CuyZ\Notiz\Core\Event\Support\ProvidesExampleProperties;
23
use TYPO3\CMS\Core\Utility\GeneralUtility;
24
use TYPO3\CMS\Scheduler\Task\AbstractTask;
0 ignored issues
show
The type TYPO3\CMS\Scheduler\Task\AbstractTask was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

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