CBitrixCloudCDN::OnEndBufferContent: Bitrix method

      
<?php 
//  CBitrixCloudCDN :: OnEndBufferContent()
//  /dist/bitrix/modules/bitrixcloud/classes/general/cdn.php:216

    
public static function OnEndBufferContent(&$content)
    {
        if (isset(
$_GET["nocdn"]))
            return;

        
$appCache = \Bitrix\Main\Data\AppCacheManifest::getInstance();
        if (
$appCache->isEnabled())
            return;

        
self::$proto CMain::IsHTTPS() ? "https" "http";
        
self::$config CBitrixCloudCDNConfig::getInstance()->loadFromOptions();

        if (
self::$config->isExpired())
        {
            if(!
self::updateConfig())
                return;
        }

        if(!
self::$config->isActive())
            return;

        
$sites self::$config->getSites();
        
$siteId defined("ADMIN_SECTION")? "admin": (defined("SITE_ID")? SITE_ID"");
        if (!isset(
$sites[$siteId]))
            return;

        
self::$ajax preg_match("/<head>/i"substr($content01024)) === 0;

        
$arPrefixes array_map(array(
            
"CBitrixCloudCDN",
            
"_preg_quote",
        ), 
self::$config->getLocationsPrefixes(self::$config->isKernelRewriteEnabled(), self::$config->isContentRewriteEnabled()));

        
$arExtensions array_map(array(
            
"CBitrixCloudCDN",
            
"_preg_quote",
        ), 
self::$config->getLocationsExtensions());

        if (!empty(
$arPrefixes) && !empty($arExtensions))
        {
            
$prefix_regex "(?:".implode("|"$arPrefixes).")";
            
$extension_regex "(?i:".implode("|"$arExtensions).")";
            
$regex "/
                ((?i:
                    (?<!;)href=
                    |(?<!;)src=
                    |BX\\.loadCSS\\(
                    |BX\\.loadScript\\(
                    |BX\\.getCDNPath\\(
                    |jsUtils\\.loadJSFile\\(
                    |background\\s*:\\s*url\\(
                    |image\\s*:\\s*url\\(
                    |'SRC':
                ))                                                   #attribute
                (\"|')                                               #open_quote
                ("
.$prefix_regex.")                                  #prefix
                ([^?'\"]+\\.)                                        #href body
                ("
.$extension_regex.")                               #extension
                (|\\?\\d+|\\?v=\\d+)                                 #params
                (\\2)                                                #close_quote
            /x"
;
            
$content preg_replace_callback($regex, array(
                
"CBitrixCloudCDN",
                
"_filter",
            ), 
$content);
        }
    }