public static function get_tag_collections() {
        global $CFG, $PAGE;

        if (empty($CFG->usetags)) {
            throw new moodle_exception('tagsaredisabled', 'tag');
        }

        $context = context_system::instance();
        self::validate_context($context);
        $PAGE->set_context($context); // Needed by internal APIs.
        $output = $PAGE->get_renderer('core');

        $collections = core_tag_collection::get_collections();
        $exportedcollections = array();
        foreach ($collections as $collection) {
            $exporter = new \core_tag\external\tag_collection_exporter($collection);
            $exportedcollections[] = $exporter->export($output);
        }

        return array(
            'collections' => $exportedcollections,
            'warnings' => array(),
        );
    }