protected static function validate_contextlist_contexts(approved_contextlist $contextlist) {
        return array_reduce($contextlist->get_contexts(), function($carry, $context) {
            if ($context->contextlevel == CONTEXT_COURSE) {
                $carry[] = $context;
            }
            return $carry;
        }, []);
    }
protected static function validate_contextlist_contexts(approved_contextlist $contextlist) {
        return array_reduce($contextlist->get_contexts(), function($carry, $context) {
            if ($context->contextlevel == CONTEXT_COURSE) {
                $carry[] = $context;
            }
            return $carry;
        }, []);
    }
protected static function validate_contextlist_contexts ( approved_contextlist $ contextlist ) { return array_reduce ( $ contextlist -> get_contexts ( ) , function ( $ carry , $ context ) { if ( $ context -> contextlevel == CONTEXT_COURSE ) { $ carry [ ] = $ context ; } return $ carry ; } , [ ] ) ; }
Simple sanity check on the contextlist contexts, making sure they're of CONTEXT_COURSE contextlevel.

@param approved_contextlist $contextlist
@return array the array of contexts filtered to only include those of CONTEXT_COURSE contextlevel.
Simple sanity check on the contextlist contexts making sure they re of CONTEXT_COURSE contextlevel .