Khaaaaaaan is a finite state machine implementation done with an extensible hook mechanism. It is designed for developers, and is very, very easy to use... at least for some definitions of 'easy'... and 'very'... and 'use'.

For example, if you want a finite state machine with seven steps (including init and finish), you would simply create a module (we'll call it "kirk") that defines these seven functions:

function kirk_khan(&$data, &$next_step) {}
function kirk_khaan(&$data, &$next_step) {}
function kirk_khaaan(&$data, &$next_step) {}
function kirk_khaaaan(&$data, &$next_step) {}
function kirk_khaaaaan(&$data, &$next_step) {}
function kirk_khaaaaaan(&$data, &$next_step) {}
function kirk_khaaaaaaan(&$data, &$next_step) {}

Want eight steps? Just add...

function kirk_khaaaaaaaan(&$data, &$next_step) {}

From there, you can just call the master Khaaaaaaan function to kick of the FSM:


Want to execute all of the Khan FSMs on your system? (Yeah, that's a good idea!) Just call the above without any parameters:


If all of this doesn't quite make sense, take a look at the example module (`genesis_device.module`) and that should clear it up. And, of course, you can always read the code of the `khaaaaaaan.module`, but I doubt it will help.


Bad judgement is required for using this module.

Project Information