- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/controller/timeline/comment.php
- Класс: Bitrix\Crm\Controller\Timeline\Comment
- Вызов: Comment::add
protected function add(int $ownerTypeId, int $ownerId, string $content, array $filesList, ?int $authorId): ?int
{
$commentId = CommentEntry::create([
'TEXT' => $content,
'FILES' => $filesList,
'SETTINGS' => ['HAS_FILES' => empty($filesList) ? 'N' : 'Y'],
'BINDINGS' => [['ENTITY_TYPE_ID' => $ownerTypeId, 'ENTITY_ID' => $ownerId]],
'AUTHOR_ID' => $authorId,
]);
if ($commentId <= 0)
{
$this->addError(new Error('Could not create comment', ErrorCode::ADDING_DISABLED));
return null;
}
CommentController::getInstance()->onCreate(
$commentId,
[
'COMMENT' => $content,
'ENTITY_TYPE_ID' => $ownerTypeId,
'ENTITY_ID' => $ownerId,
]
);
return $commentId;
}