Files
grzanieplus.pl/plugins/stTaskScheluderPlugin/lib/stTaskFactory.class.php
2025-03-12 17:06:23 +01:00

33 lines
889 B
PHP

<?php
class stTaskFactory
{
public static function createTaskById(string $taskId): stTaskInterface
{
$task = TaskPeer::retrieveByTaskId($taskId);
if (null === $task)
{
$task = new Task();
$task->setTaskId($taskId);
$task->save();
}
elseif ($task->getTaskPriority() != $task->getTaskConfigurationParameter('priority'))
{
$task->setTaskPriority($task->getTaskConfigurationParameter('priority'));
$task->save();
}
return self::createTask($task);
}
public static function createTask(Task $task)
{
$className = $task->getClassName();
$dispatcher = stEventDispatcher::getInstance();
$logger = new stTaskPropelLogger($task, $dispatcher);
return new $className($task, $logger, $dispatcher);
}
}