PHP midgard_object_class method connect_default
void connect_default(class_name, event_name, array callback, [array params])
Minimum version: Midgard 1.9
Connects default callback to event.
This method takes four arguments:
class_name, a class for which default callback is registered
event_name, a name of the event for which callback is connected to, for example
action_update_hook,action_createdoraction_loadedcallback, an array which is user defined PHP callback
params, an array with parameters which will be passed to callback
You may connect only one default callback to event. Warning is logged if you try to connect callback to an event for which default callback exists. This method deos almost the same what connect does but with one exception that there's no need to connect every single instance.
If default callback for event exists, then it's automatically connected to every new created instance.
<?php
class callback_class
{
function my_callback($object, $data)
{
echo "Connected to ".$object->guid;
echo "And have special data ".$data;
}
}
midgard_object_class::connect_default("midgard_article","action_update_hook", array("callback_class", "my_callback"), array("abc"));
$article = midgard_object_class::factory("midgard_article", 123);
$article->update();
$article_a = midgard_object_class::factory("midgard_article", 1234);
$article_a->update();
?>
Read more about events.
