ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  {
78  $detector->onActivate();
79  }
80  $this->onActivate();
81  $this->attemptTransition();
82  }
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 254 of file class.ilConditionalNode.php.

255  {
256  if (!$else_activity)
257  {
258  $this->activities[] = $activity;
259  }
260  else
261  {
262  $this->else_activities[] = $activity;
263  }
264  }

◆ 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 236 of file class.ilConditionalNode.php.

237  {
238  if (!$else_emitter)
239  {
240  $this->emitters[] = $emitter;
241  }
242  else
243  {
244  $this->else_emitters[] = $emitter;
245  }
246  }

◆ 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 133 of file class.ilConditionalNode.php.

References executeElseTransition(), and executeTransition().

Referenced by activate(), and notifyDetectorSatisfaction().

134  {
135  $eval_function = create_function('$detectors', $this->evaluation_expression);
136 
137  if ($eval_function($this->detectors) === null)
138  {
139  return false;
140  }
141 
142  if ($eval_function($this->detectors) === true)
143  {
144  $this->executeTransition();
145  return true;
146  }
147  else
148  {
149  $this->executeElseTransition();
150  return true;
151  }
152  }
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 106 of file class.ilConditionalNode.php.

107  {
108  $eval_function = create_function('$detectors', $this->evaluation_expression);
109 
110  if ($eval_function($this->detectors) === null)
111  {
112  return false;
113  }
114 
115  if ($eval_function($this->detectors) === true)
116  {
117  return true;
118  }
119  else
120  {
121  return true;
122  }
123  }

◆ deactivate()

ilConditionalNode::deactivate ( )

Deactivates the node.

Implements ilNode.

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

References ilBaseNode\onDeactivate().

Referenced by executeElseTransition(), and executeTransition().

88  {
89  $this->active = false;
90  foreach($this->detectors as $detector)
91  {
92  $detector->onDeactivate();
93  }
94  $this->onDeactivate();
95  }
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 157 of file class.ilConditionalNode.php.

Referenced by executeTransition().

158  {
159  if (count($this->activities) != 0)
160  {
161  foreach ($this->activities as $activity)
162  {
163  $activity->execute();
164  }
165  }
166  }
+ Here is the caller graph for this function:

◆ executeElseActivities()

ilConditionalNode::executeElseActivities ( )
private

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

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

Referenced by executeElseTransition().

172  {
173  if (count($this->else_activities) != 0)
174  {
175  foreach ($this->else_activities as $activity)
176  {
177  $activity->execute();
178  }
179  }
180  }
+ Here is the caller graph for this function:

◆ executeElseEmitters()

ilConditionalNode::executeElseEmitters ( )
private

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

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

Referenced by executeElseTransition().

200  {
201  if (count($this->else_emitters) != 0)
202  {
203  foreach ($this->else_emitters as $emitter)
204  {
205  $emitter->emit();
206  }
207  }
208  }
+ Here is the caller graph for this function:

◆ executeElseTransition()

ilConditionalNode::executeElseTransition ( )

Executes the 'else'-transition of the node.

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

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

Referenced by attemptTransition().

224  {
225  $this->deactivate();
226  $this->executeElseActivities();
227  $this->executeElseEmitters();
228  }
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 185 of file class.ilConditionalNode.php.

Referenced by executeTransition().

186  {
187  if (count($this->emitters) != 0)
188  {
189  foreach ($this->emitters as $emitter)
190  {
191  $emitter->emit();
192  }
193  }
194  }
+ Here is the caller graph for this function:

◆ executeTransition()

ilConditionalNode::executeTransition ( )

Executes the 'then'-transition of the node.

Implements ilNode.

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

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

Referenced by attemptTransition().

214  {
215  $this->deactivate();
216  $this->executeActivities();
217  $this->executeEmitters();
218  }
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 329 of file class.ilConditionalNode.php.

References ilBaseNode\$activities, and $else_activities.

330  {
331  if ($else)
332  {
333  return $this->else_activities;
334  }
335 
336  return $this->activities;
337  }

◆ 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 346 of file class.ilConditionalNode.php.

References $else_emitters, and ilBaseNode\$emitters.

347  {
348  if ($else)
349  {
350  return $this->else_emitters;
351  }
352 
353  return $this->emitters;
354  }

◆ 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 314 of file class.ilConditionalNode.php.

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

315  {
316  if ($this->isActive())
317  {
318  $this->attemptTransition();
319  }
320  }
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 302 of file class.ilConditionalNode.php.

303  {
304  $this->evaluation_expression = $a_expression;
305  }

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: