CBPRuntime :: SearchActivitiesByType: Bitrix method

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

    
public function SearchActivitiesByType($type, array $documentType null)
    {
        
$type strtolower(trim($type));
        if (
strlen($type) <= 0)
            return 
false;

        
$arProcessedDirs = array();
        foreach (
$this->arActivityFolders as $folder)
        {
            if (
$handle = @opendir($folder))
            {
                while (
false !== ($dir readdir($handle)))
                {
                    if (
$dir == "." || $dir == "..")
                        continue;
                    if (!
is_dir($folder."/".$dir))
                        continue;
                    
$dirKey strtolower($dir);
                    if (
array_key_exists($dirKey$arProcessedDirs))
                        continue;
                    if (!
file_exists($folder."/".$dir."/.description.php"))
                        continue;

                    
$arActivityDescription = array();
                    
$this->LoadActivityLocalization($folder."/".$dir".description.php");
                    include(
$folder."/".$dir."/.description.php");

                    
//Support multiple types
                    
$activityType = (array)$arActivityDescription['TYPE'];
                    foreach (
$activityType as $i => $aType)
                        
$activityType[$i] = strtolower(trim($aType));

                    if (
in_array($type$activityTypetrue))
                    {
                        
$arProcessedDirs[$dirKey] = $arActivityDescription;
                        
$arProcessedDirs[$dirKey]["PATH_TO_ACTIVITY"] = $folder."/".$dir;
                        if (
                            isset(
$arActivityDescription['FILTER']) && is_array($arActivityDescription['FILTER'])
                            && !
$this->checkActivityFilter($arActivityDescription['FILTER'], $documentType)
                        )
                            
$arProcessedDirs[$dirKey]['EXCLUDED'] = true;

                    }

                }
                
closedir($handle);
            }
        }

        if (
$type == 'activity')
        {
            
$arProcessedDirs array_merge($arProcessedDirs$this->getRestActivities(false$documentType));
        }

        if (
$type == 'robot_activity')
        {
            
$arProcessedDirs array_merge($arProcessedDirs$this->getRestRobots(false$documentType));
        }

        if (
$type !== 'condition')
        {
            \
Bitrix\Main\Type\Collection::sortByColumn($arProcessedDirs, ['SORT' => SORT_ASC'NAME' => SORT_ASC]);
        }

        return 
$arProcessedDirs;
    }