SourceTable::getSourceByField

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. SourceTable
  4. getSourceByField
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/tracking/internals/source.php
  • Класс: Bitrix\Crm\Tracking\Internals\SourceTable
  • Вызов: SourceTable::getSourceByField
static function getSourceByField($name, $value)
{
	static::$sources = null;
	if (static::$sources === null)
	{
		static::$sources = Tracking\Provider::getActualSources();
	}
	foreach (static::$sources as $source)
	{
		if (!isset($source[$name]))
		{
			continue;
		}

		if (is_array($source[$name]))
		{
			foreach ($source[$name] as $item)
			{
				if (is_array($item) && !empty($item['regexp']))
				{
					if (preg_match("/{$item['regexp']}/", $value))
					{
						return $source['ID'];
					}
				}
				elseif ($item == $value)
				{
					return $source['ID'];
				}
			}

			continue;
		}
		elseif ($source[$name] == $value)
		{
			return $source['ID'];
		}
	}

	return null;
}

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