ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilCounterDetector Class Reference

PhpIncludeInspection More...

+ Inheritance diagram for ilCounterDetector:
+ Collaboration diagram for ilCounterDetector:

Public Member Functions

 __construct (ilNode $context)
 Default constructor, passing the context to the parent constructor. More...
 
 setExpectedTriggerEvents ($count)
 Set the expected trigger event count before the detector is satisfied. More...
 
 getExpectedTriggerEvents ()
 Returns the currently set number of expected trigger events. More...
 
 getActualTriggerEvents ()
 Returns the actual trigger events of the detector. More...
 
 setActualTriggerEvents ($count)
 Sets the actual count of trigger events already taken place. More...
 
 trigger ($params)
 Trigger this detector. More...
 
- Public Member Functions inherited from ilSimpleDetector
 __construct (ilNode $context)
 Default constructor. More...
 
 getContext ()
 Returns the parent object. More...
 
 trigger ($params)
 Trigger this detector. More...
 
 getDetectorState ()
 Returns if the current detector state is satisfied or not. More...
 
 setDetectorState ($new_state)
 Sets a new detector state. More...
 
 onActivate ()
 Method is called, when the parent node is activated. More...
 
 onDeactivate ()
 Method is called, when the parent node is deactivated. More...
 
 getActivated ()
 
 setName ($name)
 
 getName ()
 
 getSourceNode ()
 
 setSourceNode ($source_node)
 

Private Attributes

 $expected_trigger_events = 1
 
 $actual_trigger_events = 0
 

Additional Inherited Members

- Protected Attributes inherited from ilSimpleDetector
 $name
 
 $source_node
 

Detailed Description

PhpIncludeInspection

Class ilCounterDetector

This detector has to be triggered n times before it is satisfied. It is used in looping controls and the like. This detector must not be used as external detector.

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

/

Definition at line 19 of file class.ilCounterDetector.php.

Constructor & Destructor Documentation

◆ __construct()

ilCounterDetector::__construct ( ilNode  $context)

Default constructor, passing the context to the parent constructor.

Parameters
ilNode$context

Definition at line 41 of file class.ilCounterDetector.php.

42  {
43  parent::__construct($context);
44  }

Member Function Documentation

◆ getActualTriggerEvents()

ilCounterDetector::getActualTriggerEvents ( )

Returns the actual trigger events of the detector.

Returns
integer Number of past trigger events.

Definition at line 72 of file class.ilCounterDetector.php.

References $actual_trigger_events.

◆ getExpectedTriggerEvents()

ilCounterDetector::getExpectedTriggerEvents ( )

Returns the currently set number of expected trigger events.

Returns
integer

Definition at line 61 of file class.ilCounterDetector.php.

References $expected_trigger_events.

◆ setActualTriggerEvents()

ilCounterDetector::setActualTriggerEvents (   $count)

Sets the actual count of trigger events already taken place.

Reason this method exists, is to allow the workflow controller to "fast forward" workflows to set a non-default state. I.e. a workflow has to be set into a state in the middle of running. Use with care.

Parameters
integer$countNumber of past trigger events.

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

88  {
89  if ($this->expected_trigger_events < (int) $count)
90  {
91  $this->actual_trigger_events = $count;
92  }
93  else
94  {
95  // TODO: throw actual must be smaller than expected.
96  }
97  }

◆ setExpectedTriggerEvents()

ilCounterDetector::setExpectedTriggerEvents (   $count)

Set the expected trigger event count before the detector is satisfied.

Parameters
integer$count

Definition at line 51 of file class.ilCounterDetector.php.

52  {
53  $this->expected_trigger_events = (int) $count;
54  }

◆ trigger()

ilCounterDetector::trigger (   $params)

Trigger this detector.

Params are an array. These are part of the interface but ignored here.

Todo:
Handle ignored $a_params.
Parameters
array$params
Returns
boolean False, if detector was already satisfied before.

Implements ilDetector.

Definition at line 109 of file class.ilCounterDetector.php.

References ilSimpleDetector\setDetectorState().

110  {
111  if ($this->actual_trigger_events < $this->expected_trigger_events)
112  {
113  $this->actual_trigger_events++;
114  if ($this->actual_trigger_events == $this->expected_trigger_events)
115  {
116  $this->setDetectorState(true);
117  }
118  return true;
119  }
120  return false;
121  }
setDetectorState($new_state)
Sets a new detector state.
+ Here is the call graph for this function:

Field Documentation

◆ $actual_trigger_events

ilCounterDetector::$actual_trigger_events = 0
private

Definition at line 34 of file class.ilCounterDetector.php.

Referenced by getActualTriggerEvents().

◆ $expected_trigger_events

ilCounterDetector::$expected_trigger_events = 1
private

Definition at line 26 of file class.ilCounterDetector.php.

Referenced by getExpectedTriggerEvents().


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