ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ 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\Dependencies\Injector
;
6
use
ILIAS\BackgroundTasks\Exceptions\InvalidArgumentException
;
7
use
ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\BasicScalarValueFactory
;
8
use
ILIAS\BackgroundTasks\Task
;
9
use
ILIAS\BackgroundTasks\Task\TaskFactory
;
10
use
ILIAS\BackgroundTasks\Value
;
11
12
class
BasicTaskFactory
implements
TaskFactory
13
{
14
use
BasicScalarValueFactory
;
18
protected
$injector
;
19
20
21
public
function
__construct
(
Injector
$injector
)
22
{
23
$this->injector =
$injector
;
24
}
25
26
30
public
function
createTask
($class_name,
$input
= null)
31
{
32
if
(!class_exists($class_name)) {
33
require_once(
'./src/BackgroundTasks/Implementation/Tasks/NotFoundUserInteraction.php'
);
34
return
new
NotFoundUserInteraction
();
35
}
37
$task = $this->injector->createInstance($class_name);
38
if
(!$task instanceof
Task
) {
39
throw
new
InvalidArgumentException
(
"The given classname $class_name is not a task."
);
40
}
41
if
(
$input
) {
42
$wrappedInput = array_map(
function
(
$i
) {
43
if
(
$i
instanceof Task) {
44
return
$i
->getOutput();
45
}
46
if
(
$i
instanceof
Value
) {
47
return
$i
;
48
}
49
50
return
$this->wrapValue(
$i
);
51
},
$input
);
52
53
$task->setInput($wrappedInput);
54
}
55
56
return
$task;
57
}
58
}
ILIAS\BackgroundTasks\Dependencies\Injector
Definition:
Injector.php:19
InvalidArgumentException
BasicScalarValueFactory
$input
$input
Definition:
bench_manipulatevcard.php:18
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:12
ILIAS\BackgroundTasks\Task
Definition:
Task.php:21
ILIAS\BackgroundTasks\Implementation\Tasks\BasicTaskFactory\__construct
__construct(Injector $injector)
Definition:
BasicTaskFactory.php:21
ILIAS\BackgroundTasks\Implementation\Tasks\NotFoundUserInteraction
Class NotFoundUserInteraction.
Definition:
NotFoundUserInteraction.php:14
Injector
ILIAS\BackgroundTasks\Task
Definition:
Job.php:3
TaskFactory
ILIAS\BackgroundTasks\Implementation\Tasks\BasicTaskFactory\$injector
$injector
Definition:
BasicTaskFactory.php:18
BasicScalarValueFactory
$i
$i
Definition:
disco.tpl.php:19
php
InvalidArgumentException
ILIAS\BackgroundTasks\Task\TaskFactory
Definition:
TaskFactory.php:8
Value
src
BackgroundTasks
Implementation
Tasks
BasicTaskFactory.php
Generated on Thu Jan 16 2025 19:02:36 for ILIAS by
1.8.13 (using
Doxyfile
)