Contao\Controller::setStaticUrls PHP Method

setStaticUrls() public static method

Set the static URL constants
public static setStaticUrls ( PageModel $objPage = null )
$objPage PageModel An optional page object
    public static function setStaticUrls($objPage = null)
    {
        if (defined('TL_FILES_URL')) {
            return;
        }
        // Use the global object (see #5906)
        if ($objPage === null) {
            global $objPage;
        }
        $arrConstants = array('staticFiles' => 'TL_FILES_URL', 'staticPlugins' => 'TL_ASSETS_URL');
        foreach ($arrConstants as $strKey => $strConstant) {
            $url = $objPage !== null ? $objPage->{$strKey} : \Config::get($strKey);
            if ($url == '' || \Config::get('debugMode')) {
                define($strConstant, '');
            } else {
                $strProtocol = $objPage !== null && $objPage->rootUseSSL || \Environment::get('ssl') ? 'https://' : 'http://';
                define($strConstant, $strProtocol . preg_replace('@https?://@', '', $url) . \Environment::get('path') . '/');
            }
        }
        // Deprecated since Contao 4.0, to be removed in Contao 5.0
        define('TL_SCRIPT_URL', TL_ASSETS_URL);
        define('TL_PLUGINS_URL', TL_ASSETS_URL);
    }