- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/integration/originator.php
- Класс: Bitrix\Crm\Integration\OriginatorTable
- Вызов: OriginatorTable::modifyFields
static function modifyFields(Main\ORM\Event $event)
{
$result = new Main\ORM\EventResult;
$data = $event->getParameter('fields');
if (array_key_exists('ICON', $data))
{
if ($str = \CFile::CheckImageFile($data['ICON']))
{
$result->addError(new Main\ORM\Fields\FieldError(static::getEntity()->getField('ICON_ID'), $str));
}
else
{
\CFile::ResizeImage($data['ICON'], [
'width' => Main\Config\Option::get('crm', 'originator_icon_size', 100),
'height' => Main\Config\Option::get('crm', 'originator_icon_size', 100)]);
$data['ICON']['MODULE_ID'] = 'crm';
if ($id = $event->getParameter('id'))
{
$id = is_array($id) ? reset($id) : $id;
if (is_string($id) && ($originator = OriginatorTable::getById($id)->fetchObject()))
{
$data['ICON']['old_file'] = $originator->getIconId();
}
}
if (\CFile::SaveForDB($data, 'ICON', 'crm/originator'))
{
$result->modifyFields(['ICON_ID' => $data['ICON']]);
}
}
$result->unsetField('ICON');
}
return $result;
}