• Модуль: crmmobile
  • Путь к файлу: ~/bitrix/modules/crmmobile/lib/Controller/Phone.php
  • Класс: BitrixCrmMobileControllerPhone
  • Вызов: Phone::addToContactAction
public function addToContactAction(Item $entity, string $phone, string $countryCode): bool
{
	if (empty($phone))
	{
		$errors = $this->markErrorsAsPublic([
			new Error(Loc::getMessage('M_CRM_PHONE_EMPTY')),
		]);

		$this->addErrors($errors);

		return false;
	}

	$phoneValue = (new Value())
		->setTypeId(TypePhone::ID)
		->setValueType(TypePhone::VALUE_TYPE_WORK)
		->setValueExtra((new ValueExtra())->setCountryCode($countryCode))
		->setValue($phone)
	;

	$entity->setFm($entity->getFm()->add($phoneValue));

	$operation = Container::getInstance()
		->getFactory($entity->getEntityTypeId())
		->getUpdateOperation($entity)
		->launch()
	;

	if (!$operation->isSuccess())
	{
		$errors = $this->markErrorsAsPublic($operation->getErrors());
		$this->addErrors($errors);
		return false;
	}

	return true;
}