public function get_config_for_javascript(moodle_page $page, renderer_base $renderer) {
        global $CFG;

        if (empty($this->M_cfg)) {

            $iconsystem = \core\output\icon_system::instance();

            // It is possible that the $page->context is null, so we can't use $page->context->id.
            $contextid = null;
            if (!is_null($page->context)) {
                $contextid = $page->context->id;
            }

            $this->M_cfg = array(
                'wwwroot'             => $CFG->wwwroot,
                'sesskey'             => sesskey(),
                'themerev'            => theme_get_revision(),
                'slasharguments'      => (int)(!empty($CFG->slasharguments)),
                'theme'               => $page->theme->name,
                'iconsystemmodule'    => $iconsystem->get_amd_name(),
                'jsrev'               => $this->get_jsrev(),
                'admin'               => $CFG->admin,
                'svgicons'            => $page->theme->use_svg_icons(),
                'usertimezone'        => usertimezone(),
                'contextid'           => $contextid,
            );
            if ($CFG->debugdeveloper) {
                $this->M_cfg['developerdebug'] = true;
            }
            if (defined('BEHAT_SITE_RUNNING')) {
                $this->M_cfg['behatsiterunning'] = true;
            }

        }
        return $this->M_cfg;
    }