Developing triggers

From KnowledgeTree Community

Jump to: navigation, search

Triggers allow for plugins to change the way that actions perform their work, or to perform actions when an action occurs.

Since each action is different, each trigger needs to understand what the action gives to it to either change it or to record it.

There is no base class for triggers, they simply need to implement the method that corresponds to the stage the trigger covers.

The trigger is registered with the plugin it comes with:

$oPlugin->registerTrigger('content', 'transform', 'KTWordIndexerTrigger', 'ktstandard.indexer.triggers.word', 'contents/WordIndexer.php');
  • The first parameter is the action on which the trigger acts
  • The second parameter is the stage of the action on which the trigger acts
  • The third parameter is the class that implements the trigger
  • The fourth parameter is the unique namespaced name of the trigger
  • The fifth parameter is the file which contains the implementation of the trigger (the class in the third parameter)

Generally, the action will call the setInfo method on the trigger object with the set of information that the trigger can modify, or the trigger can record (subscriptions, notifications, entries in databases, and so forth).

Generally, actions will have the following stages:

  • validate ...

...

  • postValidate which allows a trigger to occur after the action is fully completed (after the transaction is complete).

There is a pseudo-action named content, which is called when a document is added or checked-in, which has two stages: scan and transform

  • scan allows a trigger to deny the file from being added or checked in.
  • transform allows for a trigger to, amongst other things, index documents as they are checked-in.
Personal tools