CBPRestActivity::validateProperties

  1. Bitrix24 API (v. 23.675.0)
  2. bizproc
  3. CBPRestActivity
  4. validateProperties
  • Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/classes/general/restactivity.php
  • Класс: CBPRestActivity
  • Вызов: CBPRestActivity::validateProperties
static function validateProperties($testProperties = [], CBPWorkflowTemplateUser $user = null)
{
	$errors = [];

	$activityData = self::getRestActivityData();

	if (!$activityData)
	{
		return $errors;
	}

	$properties = isset($activityData['PROPERTIES']) && is_array($activityData['PROPERTIES']) ? $activityData['PROPERTIES'] : [];
	foreach ($properties as $name => $property)
	{
		$value = $testProperties[$name] ?? $property['DEFAULT'] ?? null;
		if (CBPHelper::getBool($property['REQUIRED'] ?? false) && CBPHelper::isEmptyValue($value))
		{
			$errors[] = [
				'code' => 'NotExist',
				'parameter' => $name,
				'message' => Loc::getMessage('BPRA_PD_ERROR_EMPTY_PROPERTY',
					[
						'#NAME#' => RestActivityTable::getLocalization($property['NAME'], LANGUAGE_ID),
					]
				),
			];
		}
	}

	if (
		isset($testProperties['AuthUserId'], $activityData['AUTH_USER_ID'])
		&& CBPHelper::stringify($testProperties['AuthUserId']) !== 'user_' . $activityData['AUTH_USER_ID']
		&& !static::checkAdminPermissions()
	)
	{
		$errors[] = [
			'code' => 'NotExist',
			'parameter' => 'AuthUserId',
			'message' => Loc::getMessage('BPRA_PD_ERROR_EMPTY_PROPERTY',
				[
					'#NAME#' => Loc::getMessage('BPRA_PD_USER_ID'),
				]
			),
		];
	}

	return array_merge($errors, parent::ValidateProperties($testProperties, $user));
}

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