• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/item.php
  • Класс: BitrixTasksItem
  • Вызов: Item::getInstance
static function getInstance($id, $userId = 0)
{
	$userId = intval($userId);
	if(!$userId)
	{
		$userId = Context::getDefault()->getUserId();
	}

	$id = intval($id);
	if(!$id || $id < 0)
	{
		return new static($id, $userId);
	}

	$cache =& static::getCache();
	$key = $id.'-'.$userId;

	if (!is_array($cache['ITEMS'] ?? null))
	{
		$cache['ITEMS'] = [];
	}

	if(!isset($cache['ITEMS'][$key]))
	{
		$instance = new static($id, $userId);
		$instance->setImmutable();

		$cache['ITEMS'][$key] = $instance;
	}

	return $cache['ITEMS'][$key];
}