ILIAS
release_5-3 Revision v5.3.23-19-g915713cf615
◀ ilDoc Overview
BasicTaskFactory.php
Go to the documentation of this file.
1
<?php
2
3
namespace
ILIAS\BackgroundTasks\Implementation\Tasks
;
4
5
use
ILIAS\BackgroundTasks\Exceptions\InvalidArgumentException
;
6
use
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\BasicScalarValueFactory
;
7
use
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\ScalarValueFactory
;
8
use
ILIAS\BackgroundTasks\Task
;
9
use
ILIAS\BackgroundTasks\Task\TaskFactory
;
10
use
ILIAS\BackgroundTasks\Value
;
11
use
ILIAS\BackgroundTasks\Dependencies\Injector
;
12
13
class
BasicTaskFactory
implements
TaskFactory
14
{
15
use
BasicScalarValueFactory
;
19
protected
$injector
;
20
21
22
public
function
__construct
(
Injector
$injector
)
23
{
24
$this->injector =
$injector
;
25
}
26
27
31
public
function
createTask
($class_name, $input = null)
32
{
34
$task = $this->injector->createInstance($class_name);
35
if
(!$task instanceof
Task
) {
36
throw
new
InvalidArgumentException
(
"The given classname $class_name is not a task."
);
37
}
38
if
($input) {
39
$wrappedInput = array_map(
function
(
$i
) {
40
if
(
$i
instanceof Task) {
41
return
$i
->getOutput();
42
}
43
if
(
$i
instanceof
Value
) {
44
return
$i
;
45
}
46
47
return
$this->wrapValue(
$i
);
48
}, $input);
49
50
$task->setInput($wrappedInput);
51
}
52
53
return
$task;
54
}
55
}
ILIAS\BackgroundTasks\Dependencies\Injector
Definition:
Injector.php:19
InvalidArgumentException
BasicScalarValueFactory
ILIAS\BackgroundTasks\Implementation\Tasks
Definition:
AbstractJob.php:3
ILIAS\BackgroundTasks\Task\TaskFactory\createTask
createTask($class_name, $input=null)
ILIAS\BackgroundTasks\Value
Definition:
Value.php:15
ILIAS\BackgroundTasks\Implementation\Tasks\BasicTaskFactory
Definition:
BasicTaskFactory.php:13
ILIAS\BackgroundTasks\Task
Definition:
Task.php:21
ILIAS\BackgroundTasks\Implementation\Tasks\BasicTaskFactory\__construct
__construct(Injector $injector)
Definition:
BasicTaskFactory.php:22
ScalarValueFactory
Injector
ILIAS\BackgroundTasks\Task
Definition:
Job.php:3
TaskFactory
ILIAS\BackgroundTasks\Implementation\Tasks\BasicTaskFactory\$injector
$injector
Definition:
BasicTaskFactory.php:19
BasicScalarValueFactory
$i
$i
Definition:
disco.tpl.php:19
InvalidArgumentException
ILIAS\BackgroundTasks\Task\TaskFactory
Definition:
TaskFactory.php:8
Value
src
BackgroundTasks
Implementation
Tasks
BasicTaskFactory.php
Generated on Sat Jan 18 2025 19:01:42 for ILIAS by
1.8.13 (using
Doxyfile
)