Open Source Content Management System

Version 1.5 of MgdSchema method connect

title
MgdSchema method connect
content
__void $object->connect(event_name, array callback, [!!array params])__

Minimum version: Midgard 1.9

Connects callback to [PHP Events|event].

This method takes three arguments:

- **event_name**, a name of the event for which callback is connected to, for example `action_update_hook`, `action_created` or `action_loaded`

- **callback**, an array which is user defined PHP callback

- **params**, an array with parameters which will be passed to callback

A [callback][0] function is connected to event(signal) emited by instance which invokes connect method. You may connect to one instance and event as many callbacks as you need.


function my_callback($object, $data)
{
echo "Connected to ".$object->guid;
echo "And have special data ".$data;
}

$article = midgard_object_class::factory("midgard_article", 123);
$article->connect("action_update_hook", array("my_callback"), array("abc"));

$article->update();

?>

Read more about [PHP Events|events].

[0]: http://www.php.net/callback
name
mgdschema_method_connect
topic
40
author
16
Designed by Nemein, hosted by Anykey