Contao\BackendTemplate::compile PHP Method

compile() protected method

Compile the template
protected compile ( )
    protected function compile()
    {
        // User agent class (see #3074 and #6277)
        $this->ua = \Environment::get('agent')->class;
        // Style sheets
        if (!empty($GLOBALS['TL_CSS']) && is_array($GLOBALS['TL_CSS'])) {
            $strStyleSheets = '';
            foreach (array_unique($GLOBALS['TL_CSS']) as $stylesheet) {
                $options = \StringUtil::resolveFlaggedUrl($stylesheet);
                $strStyleSheets .= \Template::generateStyleTag($this->addStaticUrlTo($stylesheet), $options->media);
            }
            $this->stylesheets = $strStyleSheets;
        }
        // JavaScripts
        if (!empty($GLOBALS['TL_JAVASCRIPT']) && is_array($GLOBALS['TL_JAVASCRIPT'])) {
            $strJavaScripts = '';
            foreach (array_unique($GLOBALS['TL_JAVASCRIPT']) as $javascript) {
                $options = \StringUtil::resolveFlaggedUrl($javascript);
                $strJavaScripts .= \Template::generateScriptTag($this->addStaticUrlTo($javascript), $options->async) . "\n";
            }
            $this->javascripts = $strJavaScripts;
        }
        // MooTools scripts (added at the page bottom)
        if (!empty($GLOBALS['TL_MOOTOOLS']) && is_array($GLOBALS['TL_MOOTOOLS'])) {
            $strMootools = '';
            foreach (array_unique($GLOBALS['TL_MOOTOOLS']) as $script) {
                $strMootools .= "\n" . trim($script) . "\n";
            }
            $this->mootools = $strMootools;
        }
        $strBuffer = $this->parse();
        $strBuffer = static::replaceOldBePaths($strBuffer);
        // HOOK: add custom output filter
        if (isset($GLOBALS['TL_HOOKS']['outputBackendTemplate']) && is_array($GLOBALS['TL_HOOKS']['outputBackendTemplate'])) {
            foreach ($GLOBALS['TL_HOOKS']['outputBackendTemplate'] as $callback) {
                $this->import($callback[0]);
                $strBuffer = $this->{$callback[0]}->{$callback[1]}($strBuffer, $this->strTemplate);
            }
        }
        $this->strBuffer = $strBuffer;
        parent::compile();
    }