• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/entity/entityeditorconfig.php
  • Класс: Bitrix\Crm\Entity\EntityEditorConfig
  • Вызов: EntityEditorConfig::check
public function check(array &$data, array &$errors)
{
	if(empty($data))
	{
		$errors[] = "There are no data";
		return false;
	}

	if(array_values($data) != $data)
	{
		$errors[] = "The data must be indexed array.";
		return false;
	}

	for($i = 0, $sectionCount = count($data); $i < $sectionCount; $i++)
	{
		if(!isset($data[$i]['type']) || trim($data[$i]['type']) === '')
		{
			$data[$i]['type'] = 'section';
		}

		if(!(isset($data[$i]['type']) && $data[$i]['type'] === 'section'))
		{
			$errors[] = "Section at index {$i} have type '{$data[$i]['type']}'. The expected type is 'section'.";
			return false;
		}

		if(!(isset($data[$i]['name']) && trim($data[$i]['name']) !== ''))
		{
			$errors[] = "Section at index {$i} does not have name.";
			return false;
		}

		if(!(isset($data[$i]['title']) && trim($data[$i]['title']) !== ''))
		{
			$errors[] = "Section at index {$i} does not have title.";
			return false;
		}

		if(!(isset($data[$i]['elements']) && is_array($data[$i]['elements'])))
		{
			$data[$i]['elements'] = array();
		}

		for($j = 0, $elementCount = count($data[$i]['elements']); $j < $elementCount; $j++)
		{
			if(!(isset($data[$i]['elements'][$j]['name']) && trim($data[$i]['elements'][$j]['name']) !== ''))
			{
				$errors[] = "Element at index {$j} in section at index {$i} does not have name.";
				return false;
			}
		}
	}

	return true;
}