Skip to content

Instantly share code, notes, and snippets.

@sundeo1
Created Nov 6, 2021
Embed
What would you like to do?
Contains callback functions for handling events
<?php
class local_test_observer
{
//Users observers
public static function user_created(\core\event\user_created $event)
{
$event_data = $event->get_data();
var_dump(json_encode($event_data));
die();
}
public static function user_deleted(\core\event\user_deleted $event)
{
$event_data = $event->get_data();
var_dump(json_encode($event_data));
die();
}
public static function user_password_updated(\core\event\user_password_updated $event)
{
$event_data = $event->get_data();
var_dump(json_encode($event_data));
die();
}
public static function user_updated(\core\event\user_updated $event)
{
$event_data = $event->get_data();
var_dump(json_encode($event_data));
die();
}
//Chapter observers
public static function chapter_created(\mod_book\event\chapter_created $event)
{
$event_data = $event->get_data();
var_dump(json_encode($event_data));
die();
}
public static function chapter_deleted(\mod_book\event\chapter_deleted $event)
{
$event_data = $event->get_data();
var_dump(json_encode($event_data));
die();
}
public static function chapter_updated(\mod_book\event\chapter_updated $event)
{
$event_data = $event->get_data();
var_dump(json_encode($event_data));
die();
}
//Course observers
public static function course_created(\core\event\course_created $event)
{
$event_data = $event->get_data();
var_dump(json_encode($event_data));
die();
}
public static function course_deleted(\core\event\course_deleted $event)
{
$event_data = $event->get_data();
var_dump($event_data);
die();
}
public static function course_module_created(\core\event\course_module_created $event)
{
$event_data = $event->get_data();
var_dump(json_encode($event_data));
die();
}
public static function course_module_deleted(\core\event\course_module_deleted $event)
{
$event_data = $event->get_data();
var_dump(json_encode($event_data));
die();
}
public static function course_module_updated(\core\event\course_module_updated $event)
{
$event_data = $event->get_data();
var_dump(json_encode($event_data));
die();
}
public static function course_restored(\core\event\course_restored $event)
{
$event_data = $event->get_data();
var_dump(json_encode($event_data));
die();
}
public static function course_updated(\core\event\course_updated $event)
{
$event_data = $event->get_data();
var_dump(json_encode($event_data));
die();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment