CBPAllStateService::GetWorkflowState: Bitrix method

      
<?php 
//  CBPAllStateService :: GetWorkflowState()
//  /dist/bitrix/modules/bizproc/classes/general/stateservice.php:286

    
public static function GetWorkflowState($workflowId)
    {
        global 
$DB;

        
$workflowId trim($workflowId);
        if (
strlen($workflowId) <= 0)
            throw new 
Exception("workflowId");

        
$dbResult $DB->Query(
            
"SELECT WS.ID, WS.WORKFLOW_TEMPLATE_ID, WS.STATE, WS.STATE_TITLE, WS.STATE_PARAMETERS, ".
            
"    ".$DB->DateToCharFunction("WS.MODIFIED""FULL")." as MODIFIED, ".
            
"    WS.MODULE_ID, WS.ENTITY, WS.DOCUMENT_ID, ".
            
"    WT.NAME, WT.DESCRIPTION, WP.OBJECT_ID, WP.PERMISSION, WI.STATUS, ".
            
"    WS.STARTED, WS.STARTED_BY, ".$DB->DateToCharFunction("WS.STARTED""FULL")." as STARTED_FORMATTED ".
            
"FROM b_bp_workflow_state WS ".
            
"    LEFT JOIN b_bp_workflow_permissions WP ON (WS.ID = WP.WORKFLOW_ID) ".
            
"    LEFT JOIN b_bp_workflow_template WT ON (WS.WORKFLOW_TEMPLATE_ID = WT.ID) ".
            
"    LEFT JOIN b_bp_workflow_instance WI ON (WS.ID = WI.ID) ".
            
"WHERE WS.ID = '".$DB->ForSql($workflowId)."' "
        
);

        
$arStates = array();
        while (
$arResult $dbResult->Fetch())
            
self::__ExtractState($arStates$arResult);

        
$keys array_keys($arStates);
        if (
count($keys) > 0)
            
$arStates $arStates[$keys[0]];

        return 
$arStates;
    }