/** * Trigger event. */ public final function trigger() { global $CFG; if ($this->restored) { throw new \coding_exception('Can not trigger restored event'); } if ($this->triggered or $this->dispatched) { throw new \coding_exception('Can not trigger event twice'); } $this->validate_before_trigger(); $this->triggered = true; if (isset($CFG->loglifetime) and $CFG->loglifetime != -1) { if ($data = $this->get_legacy_logdata()) { $manager = get_log_manager(); if (method_exists($manager, 'legacy_add_to_log')) { if (is_array($data[0])) { // Some events require several entries in 'log' table. foreach ($data as $d) { call_user_func_array(array($manager, 'legacy_add_to_log'), $d); } } else { call_user_func_array(array($manager, 'legacy_add_to_log'), $data); } } } } if (PHPUNIT_TEST and \phpunit_util::is_redirecting_events()) { $this->dispatched = true; \phpunit_util::event_triggered($this); return; } \core\event\manager::dispatch($this); $this->dispatched = true; if ($legacyeventname = static::get_legacy_eventname()) { events_trigger_legacy($legacyeventname, $this->get_legacy_eventdata()); } }
/** * Trigger event. */ public final function trigger() { global $CFG; if ($this->restored) { throw new \coding_exception('Can not trigger restored event'); } if ($this->triggered or $this->dispatched) { throw new \coding_exception('Can not trigger event twice'); } $this->validate_before_trigger(); $this->triggered = true; if (isset($CFG->loglifetime) and $CFG->loglifetime != -1) { if ($data = $this->get_legacy_logdata()) { call_user_func_array('add_to_log', $data); } } if (PHPUNIT_TEST and \phpunit_util::is_redirecting_events()) { $this->dispatched = true; \phpunit_util::event_triggered($this); return; } \core\event\manager::dispatch($this); $this->dispatched = true; if ($legacyeventname = static::get_legacy_eventname()) { events_trigger_legacy($legacyeventname, $this->get_legacy_eventdata()); } }