|
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\Service\Scheduler; |
|
19
|
|
|
|
|
20
|
|
|
use CuyZ\Notiz\Service\LocalizationService; |
|
21
|
|
|
use TYPO3\CMS\Core\Database\ConnectionPool; |
|
22
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
|
23
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
24
|
|
|
use TYPO3\CMS\Scheduler\Scheduler as CoreScheduler; |
|
|
|
|
|
|
25
|
|
|
use TYPO3\CMS\Scheduler\Task\AbstractTask; |
|
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Little service to fetch scheduler tasks, because TYPO3 core doesn't provide |
|
29
|
|
|
* any. |
|
30
|
|
|
*/ |
|
31
|
|
|
class SchedulerService implements SingletonInterface |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @var CoreScheduler |
|
35
|
|
|
*/ |
|
36
|
|
|
protected $scheduler; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Manual dependency injection. |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct() |
|
42
|
|
|
{ |
|
43
|
|
|
$this->scheduler = GeneralUtility::makeInstance(CoreScheduler::class); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Too bad we don't have a repository for this. |
|
48
|
|
|
* |
|
49
|
|
|
* @return array |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getTasksList(): array |
|
52
|
|
|
{ |
|
53
|
|
|
/** @var ConnectionPool $connectionPool */ |
|
54
|
|
|
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class); |
|
55
|
|
|
|
|
56
|
|
|
$queryBuilder = $connectionPool->getQueryBuilderForTable('tx_scheduler_task'); |
|
57
|
|
|
$queryBuilder->getRestrictions()->removeAll(); |
|
58
|
|
|
|
|
59
|
|
|
return $queryBuilder->select('*') |
|
|
|
|
|
|
60
|
|
|
->from('tx_scheduler_task') |
|
61
|
|
|
->where( |
|
62
|
|
|
$queryBuilder->expr()->eq( |
|
63
|
|
|
'disable', |
|
64
|
|
|
$queryBuilder->createNamedParameter(0, \PDO::PARAM_INT) |
|
65
|
|
|
) |
|
66
|
|
|
) |
|
67
|
|
|
->execute() |
|
68
|
|
|
->fetchAll(); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Adds all existing and enabled scheduler tasks to the given TCA array. |
|
73
|
|
|
* |
|
74
|
|
|
* @param array $parameters |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getTasksListForTca(array &$parameters) |
|
77
|
|
|
{ |
|
78
|
|
|
$parameters['items'] = array_map( |
|
79
|
|
|
function ($task) { |
|
80
|
|
|
$uid = $task['uid']; |
|
81
|
|
|
|
|
82
|
|
|
/** @var AbstractTask $taskObject */ |
|
83
|
|
|
$taskObject = unserialize($task['serialized_task_object']); |
|
84
|
|
|
|
|
85
|
|
|
$title = $this->scheduler->isValidTaskObject($taskObject) |
|
86
|
|
|
? $taskObject->getTaskTitle() |
|
87
|
|
|
: '*' . LocalizationService::localize('Event/Scheduler:task.flex_form.invalid_task') . '*'; |
|
88
|
|
|
|
|
89
|
|
|
return [ |
|
90
|
|
|
$title . ' [' . $uid . ']', |
|
91
|
|
|
$uid, |
|
92
|
|
|
]; |
|
93
|
|
|
}, |
|
94
|
|
|
$this->getTasksList() |
|
95
|
|
|
); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths