RestService::validateActivityHandler: Bitrix method

      
<?php 
//  Bitrix\Bizproc\RestService :: validateActivityHandler()
//  /dist/bitrix/modules/bizproc/lib/restservice.php:1453

    
private static function validateActivityHandler($handler$server)
    {
        
$handlerData parse_url($handler);

        if (
is_array($handlerData)
            && 
strlen($handlerData['host']) > 0
            
&& strpos($handlerData['host'], '.') > 0
        
)
        {
            if (
$handlerData['scheme'] == 'http' || $handlerData['scheme'] == 'https')
            {
                
$host $handlerData['host'];
                
$app self::getApp($server);
                if (
strlen($app['URL']) > 0)
                {
                    
$urls = array($app['URL']);

                    if (
strlen($app['URL_DEMO']) > 0)
                    {
                        
$urls[] = $app['URL_DEMO'];
                    }
                    if (
strlen($app['URL_INSTALL']) > 0)
                    {
                        
$urls[] = $app['URL_INSTALL'];
                    }

                    
$found false;
                    foreach(
$urls as $url)
                    {
                        
$a parse_url($url);
                        if (
$host == $a['host'] || $a['host'] == 'localhost')
                        {
                            
$found true;
                            break;
                        }
                    }

                    if(!
$found)
                    {
                        throw new 
RestException('Handler URL host doesn\'t match application url'self::ERROR_HANDLER_URL_MATCH);
                    }
                }
            }
            else
            {
                throw new 
RestException('Unsupported event handler protocol'self::ERROR_UNSUPPORTED_PROTOCOL);
            }
        }
        else
        {
            throw new 
RestException('Wrong handler URL'self::ERROR_WRONG_HANDLER_URL);
        }
    }