• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/Service/Factory.php
  • Класс: Bitrix\Crm\Service\Factory
  • Вызов: Factory::collectEntityTypesForPermissions
protected function collectEntityTypesForPermissions(array $filter, ?int $userId = null): array
{
	$userPermissions = Container::getInstance()->getUserPermissions($userId);
	$entityTypes = [$userPermissions::getPermissionEntityType($this->getEntityTypeId())];
	if ($this->isCategoriesSupported())
	{
		$entityTypes = [];
		$operationInfo = EntityHandler::findFieldOperation(
			Item::FIELD_NAME_CATEGORY_ID,
			$filter
		);
		if(
			is_array($operationInfo)
			&& (
				$operationInfo['OPERATION'] === '='
				|| $operationInfo['OPERATION'] === 'IN'
			)
		)
		{
			$categoryIDs = (array)($operationInfo['CONDITION']);

			foreach($categoryIDs as $categoryId)
			{
				if($categoryId >= 0)
				{
					$entityTypes[] = $userPermissions::getPermissionEntityType(
						$this->getEntityTypeId(),
						$categoryId
					);
				}
			}
		}
		else
		{
			$categories = $this->getCategories();
			foreach ($categories as $category)
			{
				$entityTypes[] = $userPermissions::getPermissionEntityType(
					$this->getEntityTypeId(),
					$category->getId()
				);
			}
		}
	}

	return $entityTypes;
}