ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilConditionalNode Class Reference

@noinspection PhpIncludeInspection More...

+ Inheritance diagram for ilConditionalNode:
+ Collaboration diagram for ilConditionalNode:

Public Member Functions

 __construct (ilWorkflow $a_context)
 Default constructor. More...
 
 activate ()
 Activates the node. More...
 
 deactivate ()
 Deactivates the node. More...
 
 checkTransitionPreconditions ()
 Checks, if the preconditions of the node to transit are met. More...
 
 attemptTransition ()
 Attempts to transit the node. More...
 
 executeTransition ()
 Executes the 'then'-transition of the node. More...
 
 executeElseTransition ()
 Executes the 'else'-transition of the node. More...
 
 addEmitter (ilEmitter $emitter, $else_emitter=false)
 Adds an emitter to one of the lists attached to the node. More...
 
 addActivity (ilActivity $activity, $else_activity=false)
 Adds an activity to one of the lists attached to the node. More...
 
 setEvaluationExpression ($a_expression)
 
 notifyDetectorSatisfaction (ilDetector $detector)
 This method is called by detectors, that just switched to being satisfied. More...
 
 getActivities ($else=false)
 Returns all currently set activites. More...
 
 getEmitters ($else=false)
 Returns all currently set emitters. More...
 
- Public Member Functions inherited from ilBaseNode
 addDetector (ilDetector $detector)
 Adds a detector to the list of detectors. More...
 
 getDetectors ()
 Returns all currently set detectors. More...
 
 addEmitter (ilEmitter $emitter)
 Adds an emitter to the list of emitters. More...
 
 getEmitters ()
 Returns all currently set emitters. More...
 
 addActivity (ilActivity $activity)
 Adds an activity to the list of activities. More...
 
 getActivities ()
 Returns all currently set activities. More...
 
 getContext ()
 Returns a reference to the parent workflow object. More...
 
 setName ($name)
 
 getName ()
 
 getRuntimeVars ()
 
 setRuntimeVars ($runtime_vars)
 
 getRuntimeVar ($name)
 
 setRuntimeVar ($name, $value)
 
 onActivate ()
 Method called on activation of the node. More...
 
 onDeactivate ()
 Method calles on deactivation of the node. More...
 
 isActive ()
 Returns the activation status of the node. More...
 
 attemptTransition ()
 
 checkTransitionPreconditions ()
 
 executeTransition ()
 
 activate ()
 
 deactivate ()
 
 notifyDetectorSatisfaction (ilDetector $detector)
 
 attemptTransition ()
 
 checkTransitionPreconditions ()
 
 executeTransition ()
 
 addDetector (ilDetector $detector)
 
 addEmitter (ilEmitter $emitter)
 
 addActivity (ilActivity $activity)
 
 activate ()
 
 deactivate ()
 
 onActivate ()
 
 onDeactivate ()
 
 notifyDetectorSatisfaction (ilDetector $detector)
 
 getDetectors ()
 
 getEmitters ()
 
 getRuntimeVars ()
 
 setRuntimeVars ($runtime_vars)
 
 getRuntimeVar ($name)
 
 setRuntimeVar ($name, $value)
 
 getContext ()
 This method returns the context of the element. More...
 
 setName ($name)
 
 getName ()
 

Private Member Functions

 executeActivities ()
 Executes all 'then'-activities attached to the node. More...
 
 executeElseActivities ()
 Exectes all 'else'-activities attached to the node. More...
 
 executeEmitters ()
 Executes all 'then'-emitters attached to the node. More...
 
 executeElseEmitters ()
 Executes all 'else'-emitters attached to the node. More...
 

Private Attributes

 $else_emitters
 
 $else_activities
 
 $evaluation_expression = "return true;"
 

Additional Inherited Members

- Protected Attributes inherited from ilBaseNode
 $context
 
 $detectors
 
 $emitters
 
 $activities
 
 $active = false
 
 $name
 
 $runtime_vars
 

Detailed Description

@noinspection PhpIncludeInspection

Conditional node of the petri net based workflow engine.

The conditional node is a deciding node. It features a doubled set of emitters and activities. The new set is prefixed with 'else_'. In the core of it, a given piece of php code is executed that returns either true, false or null, telling the node which set is to be executed - if any. This takes advantage of create_function, which is just as evil as eval. Because of that, the configuration of the conditional node must not be made available to users/admins and the content which makes up the evaluation method has no business in the database as this may pose a severe risk. Put these code pieces into the workflow object and set it during workflow creation. Remember: I told you before. Alternatively, you can extend this class and pre-set a code, that takes parameters from ilSetting, ini-Files, water diviner... up to you. Keep in mind to check these parameters for type and where possible, avoid strings and/or types that allow larger code segments.

Author
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

/

Definition at line 29 of file class.ilConditionalNode.php.

Constructor & Destructor Documentation

◆ __construct()

ilConditionalNode::__construct ( ilWorkflow  $a_context)

Default constructor.

Parameters
ilWorkflowReference to the parent workflow.

Definition at line 60 of file class.ilConditionalNode.php.

61 {
62 $this->context = $a_context;
63 $this->detectors = array();
64 $this->emitters = array();
65 $this->else_emitters = array();
66 $this->activities = array();
67 $this->else_activities = array();
68 }

Member Function Documentation

◆ activate()

ilConditionalNode::activate ( )

Activates the node.

Reimplemented from ilBaseNode.

Definition at line 73 of file class.ilConditionalNode.php.

74 {
75 $this->active = true;
76 foreach ($this->detectors as $detector) {
77 $detector->onActivate();
78 }
79 $this->onActivate();
80 $this->attemptTransition();
81 }
onActivate()
Method called on activation of the node.
attemptTransition()
Attempts to transit the node.

References attemptTransition(), and ilBaseNode\onActivate().

+ Here is the call graph for this function:

◆ addActivity()

ilConditionalNode::addActivity ( ilActivity  $activity,
  $else_activity = false 
)

Adds an activity to one of the lists attached to the node.

Parameters
ilActivity$activity
boolean$else_activityTrue, if the activity should be an 'else'-activity.

Definition at line 237 of file class.ilConditionalNode.php.

238 {
239 if (!$else_activity) {
240 $this->activities[] = $activity;
241 } else {
242 $this->else_activities[] = $activity;
243 }
244 }

◆ addEmitter()

ilConditionalNode::addEmitter ( ilEmitter  $emitter,
  $else_emitter = false 
)

Adds an emitter to one of the lists attached to the node.

Parameters
ilEmitter$emitter
boolean$else_emitterTrue, if the emitter should be an 'else'-emitter.

Definition at line 222 of file class.ilConditionalNode.php.

223 {
224 if (!$else_emitter) {
225 $this->emitters[] = $emitter;
226 } else {
227 $this->else_emitters[] = $emitter;
228 }
229 }

◆ attemptTransition()

ilConditionalNode::attemptTransition ( )

Attempts to transit the node.

Basically, this checks for preconditions and transits, returning true or false if preconditions are not met, aka detectors are not fully satisfied.

Returns
boolean True, if transition succeeded.

Reimplemented from ilBaseNode.

Definition at line 129 of file class.ilConditionalNode.php.

130 {
131 $eval_function = function ($detectors) {
132 return eval($this->evaluation_expression);
133 };
134
135 if ($eval_function($this->detectors) === null) {
136 return false;
137 }
138
139 if ($eval_function($this->detectors) === true) {
140 $this->executeTransition();
141 return true;
142 } else {
143 $this->executeElseTransition();
144 return true;
145 }
146 }
executeElseTransition()
Executes the 'else'-transition of the node.
executeTransition()
Executes the 'then'-transition of the node.

References ilBaseNode\$detectors, executeElseTransition(), and executeTransition().

Referenced by activate(), and notifyDetectorSatisfaction().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkTransitionPreconditions()

ilConditionalNode::checkTransitionPreconditions ( )

Checks, if the preconditions of the node to transit are met.

Please note, that in a conditional node, this means the node can transit to one or another outcome. This method only returns false, if the return value of the method is neither true nor false.

Returns
boolean True, if node is ready to transit.

Reimplemented from ilBaseNode.

Definition at line 104 of file class.ilConditionalNode.php.

105 {
106 $eval_function = function ($detectors) {
107 return eval($this->evaluation_expression);
108 };
109
110 if ($eval_function($this->detectors) === null) {
111 return false;
112 }
113
114 if ($eval_function($this->detectors) === true) {
115 return true;
116 } else {
117 return true;
118 }
119 }

References ilBaseNode\$detectors.

◆ deactivate()

ilConditionalNode::deactivate ( )

Deactivates the node.

Reimplemented from ilBaseNode.

Definition at line 86 of file class.ilConditionalNode.php.

87 {
88 $this->active = false;
89 foreach ($this->detectors as $detector) {
90 $detector->onDeactivate();
91 }
92 $this->onDeactivate();
93 }
onDeactivate()
Method calles on deactivation of the node.

References ilBaseNode\onDeactivate().

Referenced by executeElseTransition(), and executeTransition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeActivities()

ilConditionalNode::executeActivities ( )
private

Executes all 'then'-activities attached to the node.

Definition at line 151 of file class.ilConditionalNode.php.

152 {
153 if (count($this->activities) != 0) {
154 foreach ($this->activities as $activity) {
155 $activity->execute();
156 }
157 }
158 }

Referenced by executeTransition().

+ Here is the caller graph for this function:

◆ executeElseActivities()

ilConditionalNode::executeElseActivities ( )
private

Exectes all 'else'-activities attached to the node.

Definition at line 163 of file class.ilConditionalNode.php.

164 {
165 if (count($this->else_activities) != 0) {
166 foreach ($this->else_activities as $activity) {
167 $activity->execute();
168 }
169 }
170 }

Referenced by executeElseTransition().

+ Here is the caller graph for this function:

◆ executeElseEmitters()

ilConditionalNode::executeElseEmitters ( )
private

Executes all 'else'-emitters attached to the node.

Definition at line 187 of file class.ilConditionalNode.php.

188 {
189 if (count($this->else_emitters) != 0) {
190 foreach ($this->else_emitters as $emitter) {
191 $emitter->emit();
192 }
193 }
194 }

Referenced by executeElseTransition().

+ Here is the caller graph for this function:

◆ executeElseTransition()

ilConditionalNode::executeElseTransition ( )

Executes the 'else'-transition of the node.

Definition at line 209 of file class.ilConditionalNode.php.

210 {
211 $this->deactivate();
212 $this->executeElseActivities();
213 $this->executeElseEmitters();
214 }
executeElseActivities()
Exectes all 'else'-activities attached to the node.
deactivate()
Deactivates the node.
executeElseEmitters()
Executes all 'else'-emitters attached to the node.

References deactivate(), executeElseActivities(), and executeElseEmitters().

Referenced by attemptTransition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeEmitters()

ilConditionalNode::executeEmitters ( )
private

Executes all 'then'-emitters attached to the node.

Definition at line 175 of file class.ilConditionalNode.php.

176 {
177 if (count($this->emitters) != 0) {
178 foreach ($this->emitters as $emitter) {
179 $emitter->emit();
180 }
181 }
182 }

Referenced by executeTransition().

+ Here is the caller graph for this function:

◆ executeTransition()

ilConditionalNode::executeTransition ( )

Executes the 'then'-transition of the node.

Reimplemented from ilBaseNode.

Definition at line 199 of file class.ilConditionalNode.php.

200 {
201 $this->deactivate();
202 $this->executeActivities();
203 $this->executeEmitters();
204 }
executeEmitters()
Executes all 'then'-emitters attached to the node.
executeActivities()
Executes all 'then'-activities attached to the node.

References deactivate(), executeActivities(), and executeEmitters().

Referenced by attemptTransition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActivities()

ilConditionalNode::getActivities (   $else = false)

Returns all currently set activites.

Parameters
boolean$elseTrue, if else activities should be returned.
Returns
Array Array with objects of ilActivity

Definition at line 308 of file class.ilConditionalNode.php.

309 {
310 if ($else) {
312 }
313
314 return $this->activities;
315 }

References ilBaseNode\$activities, and $else_activities.

◆ getEmitters()

ilConditionalNode::getEmitters (   $else = false)

Returns all currently set emitters.

Parameters
boolean$elseTrue, if else emitters should be returned.
Returns
Array Array with objects of ilEmitter

Definition at line 324 of file class.ilConditionalNode.php.

325 {
326 if ($else) {
328 }
329
330 return $this->emitters;
331 }

References $else_emitters, and ilBaseNode\$emitters.

◆ notifyDetectorSatisfaction()

ilConditionalNode::notifyDetectorSatisfaction ( ilDetector  $detector)

This method is called by detectors, that just switched to being satisfied.

Parameters
ilDetector$detectorilDetector which is now satisfied.
Returns
mixed|void

Reimplemented from ilBaseNode.

Definition at line 294 of file class.ilConditionalNode.php.

295 {
296 if ($this->isActive()) {
297 $this->attemptTransition();
298 }
299 }
isActive()
Returns the activation status of the node.

References attemptTransition(), and ilBaseNode\isActive().

+ Here is the call graph for this function:

◆ setEvaluationExpression()

ilConditionalNode::setEvaluationExpression (   $a_expression)

Definition at line 282 of file class.ilConditionalNode.php.

283 {
284 $this->evaluation_expression = $a_expression;
285 }

Field Documentation

◆ $else_activities

ilConditionalNode::$else_activities
private

Definition at line 45 of file class.ilConditionalNode.php.

Referenced by getActivities().

◆ $else_emitters

ilConditionalNode::$else_emitters
private

Definition at line 37 of file class.ilConditionalNode.php.

Referenced by getEmitters().

◆ $evaluation_expression

ilConditionalNode::$evaluation_expression = "return true;"
private

Definition at line 53 of file class.ilConditionalNode.php.


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