• Модуль: rest
  • Путь к файлу: ~/bitrix/modules/rest/lib/placement.php
  • Класс: BitrixRestPlacementTable
  • Вызов: PlacementTable::modifyFields
static function modifyFields(MainORMEvent $event, MainORMEventResult $result)
{
	if ($result->getType() !== MainEntityEventResult::ERROR)
	{
		$fieldChanged = [];
		$data = array_merge($event->getParameter('fields'), $result->getModified());
		if (array_key_exists('ICON', $data))
		{
			if ($str = CFile::CheckImageFile($data['ICON']))
			{
				$result->addError(new MainORMFieldsFieldError(static::getEntity()->getField('ICON_ID'), $str));
			}
			else
			{
				CFile::ResizeImage($data['ICON'], [
					'width' => MainConfigOption::get('rest', 'icon_size', 100),
					'height' => MainConfigOption::get('rest', 'icon_size', 100)]);
				$data['ICON']['MODULE_ID'] = 'rest';
				if ($id = $event->getParameter('id'))
				{
					$id = is_integer($id) ? $id : $id['ID'];
					if ($id > 0 && ($icon = PlacementTable::getById($id)->fetchObject()))
					{
						$data['ICON']['old_file'] = $icon->getIconId();
					}
				}
				if (CFile::SaveForDB($data, 'ICON', 'rest/placementicon'))
				{
					$fieldChanged['ICON_ID'] = $data['ICON'];
				}
			}
			$result->unsetField('ICON');
		}

		if (array_key_exists('DESCRIPTION', $data))
		{
			$fieldChanged['COMMENT'] = $data['DESCRIPTION'];
			$result->unsetField('DESCRIPTION');
		}

		if (!empty($fieldChanged))
		{
			$result->modifyFields(array_merge($result->getModified(), $fieldChanged));
		}
	}

	return $result;
}