• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/helper/servicecomment.php
  • Класс: BitrixSocialnetworkHelperServiceComment
  • Вызов: ServiceComment::getSourceData
static function getSourceData(array $params = []): array
{
	$result = [];

	$sourceEntityType = ($params['sourceEntityType'] ?? false);
	$sourceEntityId = (int)($params['sourceEntityId'] ?? 0);

	if (
		in_array($sourceEntityType, [ CommentAuxCreateEntity::SOURCE_TYPE_BLOG_POST, CommentAuxCreateEntity::SOURCE_TYPE_BLOG_COMMENT ], true)
		&& Loader::includeModule('blog'))
	{
		$postId = 0;

		if ($sourceEntityType === CommentAuxCreateEntity::SOURCE_TYPE_BLOG_COMMENT)
		{
			if ($comment = CBlogComment::getById($sourceEntityId))
			{
				$postId = $comment['POST_ID'];
			}
		}
		elseif ($sourceEntityType === CommentAuxCreateEntity::SOURCE_TYPE_BLOG_POST)
		{
			$postId = $sourceEntityId;
		}

		if (
			$postId <= 0
			|| !($post = CBlogPost::getById($postId))
			|| !LivefeedBlogPost::canRead([
				'POST' => $post
			])
		)
		{
			return $result;
		}

		$blogId = (int)$post['BLOG_ID'];
		if ($blogId <= 0)
		{
			return $result;
		}

		$result = [
			'post' => $post
		];
	}

	return $result;
}