Location: PHPKode > scripts > actions_dispatcher > actions_dispatcher/example_class.inc.php
<?

	class example_class
	{
		// A function inside every of our classes to add the actions it performs
		function addactions ()
		{
			global $actions;
			// Here we add two actions, one for executing the function inside this class, called "something1", and the other for "something2".
			// The parameters for addaction are: <name for the action>, <a reference to the object wich will perform the action>, <function name inside the object>, <array of parameters to pass to the function, in the form of array ("param1", "param2", "param3" ...)
			$actions->addaction ("something_to_do_1", &$this, "something1", "");
			$actions->addaction ("something_to_do_2", &$this, "something2", "");
		}
		
		function something1 ()
		{
			// This is a very simple function, but it shows a link with a call to the Actions dispatcher (note the variable "a").
			// When we click on this link, index.php will be called, the Actions dispatcher will catch the petition (trough the "a" variable) and perform the assigned task to "something_to_do_2"
			echo "Something to do 1, click <a href=\"index.php?a=something_to_do_2\">here</a> to perform the action 'something_to_do_2'<br>";
		}
		
		function something2 ()
		{
			echo "Something to do 2.<br>";
		}
		
		function default_action ()
		{
			echo "The default action has been called, you haven't passed the action parameter (a), or there aren't any action refering to it.<br>";
		}
	}

?>
Return current item: actions_dispatcher