ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilConditionalNode Class Reference

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)
 

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

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.

References array.

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  }
Create styles array
The data for the language used.

Member Function Documentation

◆ activate()

ilConditionalNode::activate ( )

Activates the node.

Implements ilNode.

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

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

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

Implements ilNode.

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

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

Referenced by activate(), and notifyDetectorSatisfaction().

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  }
executeTransition()
Executes the 'then'-transition of the node.
executeElseTransition()
Executes the 'else'-transition of the node.
+ 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.

Implements ilNode.

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

References ilBaseNode\$detectors.

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  }

◆ deactivate()

ilConditionalNode::deactivate ( )

Deactivates the node.

Implements ilNode.

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

References ilBaseNode\onDeactivate().

Referenced by executeElseTransition(), and executeTransition().

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.
+ 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.

Referenced by executeTransition().

152  {
153  if (count($this->activities) != 0) {
154  foreach ($this->activities as $activity) {
155  $activity->execute();
156  }
157  }
158  }
+ 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.

Referenced by executeElseTransition().

164  {
165  if (count($this->else_activities) != 0) {
166  foreach ($this->else_activities as $activity) {
167  $activity->execute();
168  }
169  }
170  }
+ 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.

Referenced by executeElseTransition().

188  {
189  if (count($this->else_emitters) != 0) {
190  foreach ($this->else_emitters as $emitter) {
191  $emitter->emit();
192  }
193  }
194  }
+ 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.

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

Referenced by attemptTransition().

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

Referenced by executeTransition().

176  {
177  if (count($this->emitters) != 0) {
178  foreach ($this->emitters as $emitter) {
179  $emitter->emit();
180  }
181  }
182  }
+ Here is the caller graph for this function:

◆ executeTransition()

ilConditionalNode::executeTransition ( )

Executes the 'then'-transition of the node.

Implements ilNode.

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

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

Referenced by attemptTransition().

200  {
201  $this->deactivate();
202  $this->executeActivities();
203  $this->executeEmitters();
204  }
executeActivities()
Executes all 'then'-activities attached to the node.
deactivate()
Deactivates the node.
executeEmitters()
Executes all 'then'-emitters attached to the node.
+ 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.

References ilBaseNode\$activities, and $else_activities.

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

◆ 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.

References $else_emitters, and ilBaseNode\$emitters.

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

◆ 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

Implements ilNode.

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

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

295  {
296  if ($this->isActive()) {
297  $this->attemptTransition();
298  }
299  }
attemptTransition()
Attempts to transit the node.
isActive()
Returns the activation status of the node.
+ 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: