public static function get_calendar_event_by_id($eventid) {
        global $PAGE, $USER;

        $params = self::validate_parameters(self::get_calendar_event_by_id_parameters(), ['eventid' => $eventid]);
        $context = \context_user::instance($USER->id);

        self::validate_context($context);
        $warnings = array();

        $legacyevent = calendar_event::load($eventid);
        // Must check we can see this event.
        if (!calendar_view_event_allowed($legacyevent)) {
            // We can't return a warning in this case because the event is not optional.
            // We don't know the context for the event and it's not worth loading it.
            $syscontext = context_system::instance();
            throw new \required_capability_exception($syscontext, 'moodle/course:view', 'nopermission', '');
        }

        $legacyevent->count_repeats();

        $eventmapper = event_container::get_event_mapper();
        $event = $eventmapper->from_legacy_event_to_event($legacyevent);

        $cache = new events_related_objects_cache([$event]);
        $relatedobjects = [
            'context' => $cache->get_context($event),
            'course' => $cache->get_course($event),
        ];

        $exporter = new event_exporter($event, $relatedobjects);
        $renderer = $PAGE->get_renderer('core_calendar');

        return array('event' => $exporter->export($renderer), 'warnings' => $warnings);
    }
public static function get_calendar_event_by_id($eventid) {
        global $PAGE, $USER;

        $params = self::validate_parameters(self::get_calendar_event_by_id_parameters(), ['eventid' => $eventid]);
        $context = \context_user::instance($USER->id);

        self::validate_context($context);
        $warnings = array();

        $legacyevent = calendar_event::load($eventid);
        // Must check we can see this event.
        if (!calendar_view_event_allowed($legacyevent)) {
            // We can't return a warning in this case because the event is not optional.
            // We don't know the context for the event and it's not worth loading it.
            $syscontext = context_system::instance();
            throw new \required_capability_exception($syscontext, 'moodle/course:view', 'nopermission', '');
        }

        $legacyevent->count_repeats();

        $eventmapper = event_container::get_event_mapper();
        $event = $eventmapper->from_legacy_event_to_event($legacyevent);

        $cache = new events_related_objects_cache([$event]);
        $relatedobjects = [
            'context' => $cache->get_context($event),
            'course' => $cache->get_course($event),
        ];

        $exporter = new event_exporter($event, $relatedobjects);
        $renderer = $PAGE->get_renderer('core_calendar');

        return array('event' => $exporter->export($renderer), 'warnings' => $warnings);
    }
public static function get_calendar_event_by_id ( $ eventid ) { global $ PAGE , $ USER ; $ params = self :: validate_parameters ( self :: get_calendar_event_by_id_parameters ( ) , [ 'eventid' => $ eventid ] ) ; $ context = \ context_user :: instance ( $ USER -> id ) ; self :: validate_context ( $ context ) ; $ warnings = array ( ) ; $ legacyevent = calendar_event :: load ( $ eventid ) ; // Must check we can see this event. if ( ! calendar_view_event_allowed ( $ legacyevent ) ) { // We can't return a warning in this case because the event is not optional. // We don't know the context for the event and it's not worth loading it. $ syscontext = context_system :: instance ( ) ; throw new \ required_capability_exception ( $ syscontext , 'moodle/course:view' , 'nopermission' , '' ) ; } $ legacyevent -> count_repeats ( ) ; $ eventmapper = event_container :: get_event_mapper ( ) ; $ event = $ eventmapper -> from_legacy_event_to_event ( $ legacyevent ) ; $ cache = new events_related_objects_cache ( [ $ event ] ) ; $ relatedobjects = [ 'context' => $ cache -> get_context ( $ event ) , 'course' => $ cache -> get_course ( $ event ) , ] ; $ exporter = new event_exporter ( $ event , $ relatedobjects ) ; $ renderer = $ PAGE -> get_renderer ( 'core_calendar' ) ; return array ( 'event' => $ exporter -> export ( $ renderer ) , 'warnings' => $ warnings ) ; }
Get calendar event by id.

@param int $eventid The calendar event id to be retrieved.
@return array Array of event details
Get calendar event by id .