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