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\Container; |
21
|
|
|
use Throwable; |
22
|
|
|
use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; |
|
|
|
|
23
|
|
|
use TYPO3\CMS\Scheduler\Task\AbstractTask; |
|
|
|
|
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Overrides the TYPO3 core class in order to send signals on which NotiZ can |
27
|
|
|
* bind events. |
28
|
|
|
* |
29
|
|
|
* Two signals are sent: |
30
|
|
|
* |
31
|
|
|
* Signal: task was executed |
32
|
|
|
* ------------------------- |
33
|
|
|
* |
34
|
|
|
* @see \CuyZ\Notiz\Service\Scheduler\Scheduler::SIGNAL_TASK_EXECUTED |
35
|
|
|
* |
36
|
|
|
* When a task was successfully executed. |
37
|
|
|
* |
38
|
|
|
* Two arguments are given to the slot: |
39
|
|
|
* |
40
|
|
|
* - `$task` - @see \TYPO3\CMS\Scheduler\Task\AbstractTask |
41
|
|
|
* The executed task instance containing useful information. |
42
|
|
|
* |
43
|
|
|
* - `$result` - bool |
44
|
|
|
* Result returned by the task execution process. |
45
|
|
|
* |
46
|
|
|
* Signal: task execution failed |
47
|
|
|
* ----------------------------- |
48
|
|
|
* |
49
|
|
|
* @see \CuyZ\Notiz\Service\Scheduler\Scheduler::SIGNAL_TASK_FAILED |
50
|
|
|
* |
51
|
|
|
* When something has gone wrong during the execution of the task (an exception |
52
|
|
|
* has been thrown). |
53
|
|
|
* |
54
|
|
|
* Two arguments are given to the slot: |
55
|
|
|
* |
56
|
|
|
* - `$task` - @see \TYPO3\CMS\Scheduler\Task\AbstractTask |
57
|
|
|
* The executed task instance containing useful information. |
58
|
|
|
* |
59
|
|
|
* - `$exception` - @see \Throwable |
60
|
|
|
* The exception that was thrown during the execution. |
61
|
|
|
*/ |
62
|
|
|
class Scheduler extends \TYPO3\CMS\Scheduler\Scheduler |
|
|
|
|
63
|
|
|
{ |
64
|
|
|
const SIGNAL_TASK_EXECUTED = 'taskWasExecuted'; |
65
|
|
|
|
66
|
|
|
const SIGNAL_TASK_FAILED = 'taskExecutionFailed'; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @var Dispatcher |
70
|
|
|
*/ |
71
|
|
|
protected $dispatcher; |
72
|
|
|
|
73
|
|
|
public function __construct() |
74
|
|
|
{ |
75
|
|
|
parent::__construct(); |
76
|
|
|
|
77
|
|
|
$this->dispatcher = Container::get(Dispatcher::class); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* See class description for more information. |
82
|
|
|
* |
83
|
|
|
* @param AbstractTask $task |
84
|
|
|
* @return bool |
85
|
|
|
* |
86
|
|
|
* @throws Throwable |
87
|
|
|
*/ |
88
|
|
|
public function executeTask(AbstractTask $task): bool |
89
|
|
|
{ |
90
|
|
|
$exception = null; |
|
|
|
|
91
|
|
|
|
92
|
|
|
try { |
93
|
|
|
$result = parent::executeTask($task); |
94
|
|
|
|
95
|
|
|
$this->dispatcher->dispatch( |
96
|
|
|
__CLASS__, |
97
|
|
|
self::SIGNAL_TASK_EXECUTED, |
98
|
|
|
[$task, $result] |
99
|
|
|
); |
100
|
|
|
|
101
|
|
|
return $result; |
102
|
|
|
} catch (Throwable $exception) { |
103
|
|
|
$this->dispatcher->dispatch( |
104
|
|
|
__CLASS__, |
105
|
|
|
self::SIGNAL_TASK_FAILED, |
106
|
|
|
[$task, $exception] |
107
|
|
|
); |
108
|
|
|
|
109
|
|
|
throw $exception; |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
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