Scope::getUserScopes

  1. Bitrix24 API (v. 23.675.0)
  2. ui
  3. Scope
  4. getUserScopes
  • Модуль: ui
  • Путь к файлу: ~/bitrix/modules/ui/lib/entityform/scope.php
  • Класс: BitrixUiEntityFormScope
  • Вызов: Scope::getUserScopes
public function getUserScopes(string $entityTypeId, ?string $moduleId = null): array
{
	static $results = [];
	$key = $entityTypeId . '-' . $moduleId;

	if (!isset($results[$key]))
	{
		$result = [];
		$scopeIds = $this->getScopesIdByUser($moduleId);
		$entityTypeIds = ($this->getEntityTypeIdMap()[$entityTypeId] ?? [$entityTypeId]);

		if (!empty($scopeIds))
		{
			$scopes = EntityFormConfigTable::getList([
				'select' => [
					'ID',
					'NAME',
					'ACCESS_CODE' => 'BitrixUiEntityFormEntityFormConfigAcTable:CONFIG.ACCESS_CODE'
				],
				'filter' => [
					'@ID' => $scopeIds,
					'@ENTITY_TYPE_ID' => $entityTypeIds
				]
			]);
			foreach ($scopes as $scope)
			{
				$result[$scope['ID']]['NAME'] = HtmlFilter::encode($scope['NAME']);
				if (!isset($result[$scope['ID']]['ACCESS_CODES'][$scope['ACCESS_CODE']]))
				{
					$accessCode = new AccessCode($scope['ACCESS_CODE']);
					$member = (new DataProvider())->getEntity($accessCode->getEntityType(),
						$accessCode->getEntityId());
					$result[$scope['ID']]['ACCESS_CODES'][$scope['ACCESS_CODE']] = $scope['ACCESS_CODE'];
					$result[$scope['ID']]['MEMBERS'][$scope['ACCESS_CODE']] = $member->getMetaData();
				}
			}
		}
		$results[$key] = $result;
	}

	return $results[$key];
}

Добавить комментарий