CBPRuntime :: IncludeActivityFile: Bitrix method

      
<?php 
//  CBPRuntime :: IncludeActivityFile()
//  /dist/bitrix/modules/bizproc/classes/general/runtime.php:393

    
public function IncludeActivityFile($code)
    {
        if (
in_array($code$this->arLoadedActivities))
            return 
true;

        if (
preg_match("#[^a-zA-Z0-9_]#"$code))
            return 
false;
        if (
strlen($code) <= 0)
            return 
false;

        
$code strtolower($code);
        if (
substr($code03) == "cbp")
            
$code substr($code3);
        if (
strlen($code) <= 0)
            return 
false;
        if (
in_array($code$this->arLoadedActivities))
            return 
true;

        
$filePath "";
        
$fileDir "";
        foreach (
$this->arActivityFolders as $folder)
        {
            if (
file_exists($folder."/".$code."/".$code.".php") && is_file($folder."/".$code."/".$code.".php"))
            {
                
$filePath $folder."/".$code."/".$code.".php";
                
$fileDir $folder."/".$code;
                break;
            }
        }

        if (
strlen($filePath) > 0)
        {
            
$this->LoadActivityLocalization($fileDir$code.".php");
            include_once(
$filePath);
            
$this->arLoadedActivities[] = $code;
            return 
true;
        }

        if (
strpos($code, static::REST_ACTIVITY_PREFIX) === 0)
        {
            
$code substr($codestrlen(static::REST_ACTIVITY_PREFIX));
            
$result RestActivityTable::getList(array(
                
'select' => array('ID'),
                
'filter' => array('=INTERNAL_CODE' => $code)
            ));
            
$activity $result->fetch();
            eval(
'class CBP'.static::REST_ACTIVITY_PREFIX.$code.' extends CBPRestActivity {const REST_ACTIVITY_ID = '.($activity$activity['ID'] : 0).';}');
            
$this->arLoadedActivities[] = static::REST_ACTIVITY_PREFIX.$code;
            return 
true;
        }

        return 
false;
    }