ILIAS  trunk Revision v11.0_alpha-1861-g09f3d197f78
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask Class Reference
+ Inheritance diagram for ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask:
+ Collaboration diagram for ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask:

Public Member Functions

 setInput (array $values)
 
 getOutput ()
 
 getInput ()
 
 getType ()
 
 unfoldTask ()
 Unfold the task. More...
 
 getRemoveOption ()
 
Returns
Option An Option to remove the current task and do some cleanup if possible. This Option is displayed if the Bucket is completed. You do not have to provide an additional Option to remove in your UserInteraction, the remove-Option is added to the list of Options (last position)
See also
self::getAbortOption();
More...
 
 getAbortOption ()
 
Returns
Option In case a Job is failed or did not respond for some time, an Abort-Option is displayed. There is already a Standard-Abort-Option registered, you can override with your own and do some cleanup if possible.
More...
 
- Public Member Functions inherited from ILIAS\BackgroundTasks\Task
 getInputTypes ()
 
 getOutputType ()
 

Data Fields

const MAIN_REMOVE = 'bt_main_remove'
 
const MAIN_ABORT = 'bt_main_abort'
 

Protected Member Functions

 checkTypes (array $values)
 
 extractType ($value)
 

Protected Attributes

array $input = []
 
Value $output
 

Private Member Functions

 getValues (array $values)
 

Detailed Description

Definition at line 35 of file AbstractTask.php.

Member Function Documentation

◆ checkTypes()

ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask::checkTypes ( array  $values)
protected

Definition at line 56 of file AbstractTask.php.

References ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\extractType(), and ILIAS\BackgroundTasks\Task\getInputTypes().

Referenced by ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\setInput().

57  {
58  $expectedTypes = $this->getInputTypes();
59 
60  foreach ($expectedTypes as $i => $expectedType) {
61  $givenType = $this->extractType($values[$i]);
62  if (!$givenType->isExtensionOf($expectedType)) {
63  throw new InvalidArgumentException("Types did not match when setting input for "
64  . static::class
65  . ". Expected type $expectedType given type $givenType.");
66  }
67  }
68  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extractType()

ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask::extractType (   $value)
protected
Parameters
$valueValue|Task
Exceptions
InvalidArgumentException

Definition at line 74 of file AbstractTask.php.

Referenced by ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\checkTypes().

74  : Type
75  {
76  if (is_a($value, Value::class)) {
77  return $value->getType();
78  }
79  if (is_a($value, Task::class)) {
80  return $value->getOutputType();
81  }
82 
83  throw new InvalidArgumentException("Input values must be Tasks or Values (extend BT\\Task or BT\\Value).");
84  }
+ Here is the caller graph for this function:

◆ getAbortOption()

ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask::getAbortOption ( )

Returns
Option In case a Job is failed or did not respond for some time, an Abort-Option is displayed. There is already a Standard-Abort-Option registered, you can override with your own and do some cleanup if possible.

Implements ILIAS\BackgroundTasks\Task.

Definition at line 160 of file AbstractTask.php.

160  : Option
161  {
162  return new UserInteractionOption('abort', self::MAIN_ABORT);
163  }

◆ getInput()

ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask::getInput ( )
Returns
Value[]

Implements ILIAS\BackgroundTasks\Task.

Definition at line 122 of file AbstractTask.php.

References ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\$input.

Referenced by ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\unfoldTask().

122  : array
123  {
124  return $this->input;
125  }
+ Here is the caller graph for this function:

◆ getOutput()

ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask::getOutput ( )
Returns
Value Returns a thunk value (yet to be calculated). It's used for task composition and type checks.

Implements ILIAS\BackgroundTasks\Task.

Definition at line 90 of file AbstractTask.php.

References ILIAS\BackgroundTasks\Task\getOutputType().

90  : Value
91  {
92  $thunk = new ThunkValue($this->getOutputType());
93  $thunk->setParentTask($this);
94 
95  return $thunk;
96  }
+ Here is the call graph for this function:

◆ getRemoveOption()

ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask::getRemoveOption ( )

Returns
Option An Option to remove the current task and do some cleanup if possible. This Option is displayed if the Bucket is completed. You do not have to provide an additional Option to remove in your UserInteraction, the remove-Option is added to the list of Options (last position)
See also
self::getAbortOption();

Implements ILIAS\BackgroundTasks\Task.

Definition at line 152 of file AbstractTask.php.

152  : Option
153  {
154  return new UserInteractionOption('remove', self::MAIN_REMOVE);
155  }

◆ getType()

ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask::getType ( )

Implements ILIAS\BackgroundTasks\Task.

Definition at line 127 of file AbstractTask.php.

127  : string
128  {
129  return static::class;
130  }

◆ getValues()

ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask::getValues ( array  $values)
private
Parameters
$values(Value|Task)[]
Returns
Value[]

Definition at line 102 of file AbstractTask.php.

References ILIAS\UI\Implementation\Component\Input\$inputs.

Referenced by ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\setInput().

102  : array
103  {
104  $inputs = [];
105 
106  foreach ($values as $value) {
107  if ($value instanceof Task) {
108  $inputs[] = $value->getOutput();
109  } elseif ($value instanceof Value) {
110  $inputs[] = $value;
111  } else {
112  $inputs[] = $this->wrapScalar($value);
113  }
114  }
115 
116  return $inputs;
117  }
+ Here is the caller graph for this function:

◆ setInput()

ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask::setInput ( array  $values)
Parameters
Value[]|Task[]$values

Implements ILIAS\BackgroundTasks\Task.

Definition at line 50 of file AbstractTask.php.

References ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\checkTypes(), and ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\getValues().

50  : void
51  {
52  $this->input = $this->getValues($values);
53  $this->checkTypes($this->input);
54  }
+ Here is the call graph for this function:

◆ unfoldTask()

ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask::unfoldTask ( )

Unfold the task.

If task A has dependency B and B' and B has dependency C, the resulting list will be [A, B, C, B'].

Returns
Task[]

Implements ILIAS\BackgroundTasks\Task.

Definition at line 137 of file AbstractTask.php.

References ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask\getInput().

137  : array
138  {
139  $list = [$this];
140  foreach ($this->getInput() as $input) {
141  if ($input instanceof ThunkValue) {
142  $list = array_merge($list, $input->getParentTask()->unfoldTask());
143  }
144  }
145 
146  return $list;
147  }
+ Here is the call graph for this function:

Field Documentation

◆ $input

◆ $output

Value ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask::$output
protected

◆ MAIN_ABORT

const ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask::MAIN_ABORT = 'bt_main_abort'

Definition at line 40 of file AbstractTask.php.

◆ MAIN_REMOVE

const ILIAS\BackgroundTasks\Implementation\Tasks\AbstractTask::MAIN_REMOVE = 'bt_main_remove'

Definition at line 39 of file AbstractTask.php.


The documentation for this class was generated from the following file: