From 129b09ad2fda3363f6e3fda2b32f57f703007bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Jedenastik?= Date: Fri, 15 Apr 2022 16:22:45 +0200 Subject: [PATCH] TASK: TaskCollectionFactory ignores non existing configured handlerClass and writes message to log --- Classes/Domain/Task/TaskCollectionFactory.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Classes/Domain/Task/TaskCollectionFactory.php b/Classes/Domain/Task/TaskCollectionFactory.php index 246671c..615051c 100644 --- a/Classes/Domain/Task/TaskCollectionFactory.php +++ b/Classes/Domain/Task/TaskCollectionFactory.php @@ -5,12 +5,19 @@ use Cron\CronExpression; use Neos\Flow\Annotations as Flow; +use Neos\Flow\Log\Utility\LogEnvironment; +use Psr\Log\LoggerInterface; /** * @Flow\Scope("singleton") */ class TaskCollectionFactory { + /** + * @Flow\Inject + * @var LoggerInterface + */ + protected $systemLogger; /** * @Flow\InjectConfiguration(package="Flowpack.Task", path="tasks") @@ -32,6 +39,11 @@ public function buildTasksFromConfiguration(): TaskCollection $cronExpressionPattern = $taskConfiguration['cronExpression'] ?? ''; $cronExpression = $cronExpressionPattern !== '' ? new CronExpression($cronExpressionPattern) : null; + if (!class_exists($taskConfiguration['handlerClass'])) { + $this->systemLogger->info(sprintf('Taskhandler class not found - Task "%s" is ignored', $taskConfiguration['handlerClass']), LogEnvironment::fromMethodName(__METHOD__)); + continue; + } + $this->taskCollection->set($taskIdentifier, new Task( $taskIdentifier, $cronExpression,