• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/statusbase.php
  • Класс: BitrixSaleStatusBase
  • Вызов: StatusBase::install
static function install(array $data)
{
	if (! ($statusId = $data['ID']) || ! is_string($statusId))
	{
		throw new SystemException('invalid status ID', 0, __FILE__, __LINE__);
	}

	if ($languages = $data['LANG'])
	{
		unset($data['LANG']);

		if (! is_array($languages))
			throw new SystemException('invalid status LANG', 0, __FILE__, __LINE__);
	}

	$data['TYPE'] = static::TYPE;

	// install status if it is not installed

	if (! StatusTable::getById($statusId)->fetch())
	{
		StatusTable::add($data);
	}

	// install status languages if they are not installed

	if ($languages)
	{
		$installedLanguages = array();

		$result = StatusLangTable::getList(array(
			'select' => array('LID'),
			'filter' => array('=STATUS_ID' => $statusId),
		));

		while ($row = $result->fetch())
		{
			$installedLanguages[$row['LID']] = true;
		}

		foreach ($languages as $language)
		{
			if (! is_array($language))
				throw new SystemException('invalid status language', 0, __FILE__, __LINE__);

			if (! $installedLanguages[$language['LID']])
			{
				$language['STATUS_ID'] = $statusId;

				StatusLangTable::add($language);
			}
		}
	}
}