public static function apply_component_is_event_visible(event_interface $event) {
        $mapper = self::$eventmapper;
        $eventvisible = null;
        if ($event->get_course_module()) {
            $requestinguserid = self::get_requesting_user();
            $legacyevent = $mapper->from_event_to_legacy_event($event);
            // We know for a fact that the the requesting user might be different from the logged in user,
            // but the event mapper is not aware of that.
            if (empty($event->user) && !empty($legacyevent->userid)) {
                $legacyevent->userid = $requestinguserid;
            }

            // TODO MDL-58866 Only activity modules currently support this callback.
            $eventvisible = component_callback(
                'mod_' . $event->get_course_module()->get('modname'),
                'core_calendar_is_event_visible',
                [
                    $legacyevent,
                    $requestinguserid
                ]
            );
        }

        // Do not display the event if there is nothing to action.
        if ($event instanceof action_event_interface && $event->get_action()->get_item_count() === 0) {
            return false;
        }

        // Module does not implement the callback, event should be visible.
        if (is_null($eventvisible)) {
            return true;
        }

        return $eventvisible ? true : false;
    }