ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
BasicTaskFactory.php
Go to the documentation of this file.
1<?php
2
4
6use ILIAS\BackgroundTasks\Implementation\Values\ScalarValues\BasicScalarValueFactory;
12
14{
15 use BasicScalarValueFactory;
19 protected $injector;
20
21
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}
An exception for terminatinating execution or to throw for unit testing.
$i
Definition: disco.tpl.php:19
createTask($class_name, $input=null)