public static function get_tag_areas() {
        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');

        $areas = core_tag_area::get_areas();
        $exportedareas = array();
        foreach ($areas as $itemtype => $component) {
            foreach ($component as $area) {
                // Move optional fields not part of the DB table to otherdata.
                $locked = false;
                if (isset($area->locked)) {
                    $locked = $area->locked;
                    unset($area->locked);
                }
                $exporter = new \core_tag\external\tag_area_exporter($area, array('locked' => $locked));
                $exportedareas[] = $exporter->export($output);
            }
        }

        return array(
            'areas' => $exportedareas,
            'warnings' => array(),
        );
    }