• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/lib/placement.php
  • Класс: BitrixRestPlacementTable
  • Вызов: PlacementTable::getHandlersList
static function getHandlersList($placement, $skipInstallCheck = false, int $userId = null)
{
	if(!array_key_exists($placement, static::$handlersListCache))
	{
		static::$handlersListCache[$placement] = array();

		$cache = MainApplication::getInstance()->getManagedCache();
		if($cache->read(static::CACHE_TTL, static::getCacheId($placement), static::CACHE_DIR))
		{
			static::$handlersListCache = $cache->get(static::getCacheId($placement));
		}
		else
		{
			$res = static::getHandlers($placement, $userId);
			foreach ($res->fetchCollection() as $handler)
			{
				$id = $handler->getId();
				$app = $handler->getRestApp();
				$placementItem = [
					'ID' => $id,
					'APP_ID' => $handler->getAppId(),
					'USER_ID' => $handler->getUserId(),
					'ICON_ID' => $handler->getIconId(),
					'ADDITIONAL' => $handler->getAdditional(),
					'TITLE' => '',
					/**
					 * @deprecated
					 * Use DESCRIPTION
					 */
					'COMMENT' => '',
					'DESCRIPTION' => '',
					'GROUP_NAME' => '',
					'OPTIONS' => $handler->getOptions(),
					'INSTALLED' => $app->getInstalled(),
					'APP_NAME' => $app->getAppName(),
					'APP_ACCESS' => $app->getAccess(),
					'LANG_ALL' => [],
				];

				if ($placementItem['ICON_ID'] > 0 && ($file = CFile::GetFileArray($placementItem['ICON_ID'])))
				{
					$placementItem['ICON'] = array_change_key_case($file, CASE_LOWER);
				}

				$handler->fillLangAll();
				if (!is_null($handler->getLangAll()))
				{
					foreach ($handler->getLangAll() as $lang)
					{
						$placementItem['LANG_ALL'][$lang->getLanguageId()] = [
							'TITLE' => $lang->getTitle(),
							'DESCRIPTION' => $lang->getDescription(),
							'GROUP_NAME' => $lang->getGroupName(),
						];
					}
				}
				static::$handlersListCache[$placement][] = $placementItem;
			}

			$cache->set(static::getCacheId($placement), static::$handlersListCache);
		}
	}

	$result = static::$handlersListCache[$placement];

	foreach($result as $key => $handler)
	{
		if(!$skipInstallCheck && $handler['INSTALLED'] === AppTable::NOT_INSTALLED)
		{
			unset($result[$key]);
		}
		elseif(
			$placement !== ApiUserFieldType::PLACEMENT_UF_TYPE
			&& !CRestUtil::checkAppAccess($handler['APP_ID'], array(
				'ACCESS' => $handler['APP_ACCESS']
			)
			)
		)
		{
			unset($result[$key]);
		}
		else
		{
			$result[$key] = Lang::mergeFromLangAll($handler);
			if (empty($result[$key]['TITLE']))
			{
				$result[$key]['TITLE'] = static::getDefaultTitle($handler['ID']);
			}
		}
	}

	$result = array_values($result);

	return $result;
}