• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/Message/ParamArray.php
  • Класс: BitrixImV2MessageParamArray
  • Вызов: ParamArray::setValue
public function setValue($values): self
{
	if (!is_array($values))
	{
		$values = [$values];
	}
	switch ($this->type)
	{
		case Param::TYPE_INT_ARRAY:
			$values = array_map('intVal', $values);
			break;

		case Param::TYPE_STRING:
			$values = array_map('strVal', $values);
	}

	foreach ($this as $param)
	{
		if (!$param->isDeleted() && in_array($param->getValue(), $values, true))
		{
			$inx = array_search($param->getValue(), $values, true);
			if ($inx !== false)
			{
				unset($values[$inx]);
			}
		}
		else
		{
			$param->markDrop();
			$this->markChanged();
		}
	}

	if (!empty($values))
	{
		foreach ($values as $value)
		{
			$this->addValue($value);
		}

		$this->markChanged();
	}

	return $this;
}