Comment::getById

  1. Bitrix24 API (v. 23.675.0)
  2. blog
  3. Comment
  4. getById
  • Модуль: blog
  • Путь к файлу: ~/bitrix/modules/blog/lib/item/comment.php
  • Класс: BitrixBlogItemComment
  • Вызов: Comment::getById
static function getById($commentId = 0)
{
	static $cachedFields = array();

	$commentItem = false;
	$commentId = (int)$commentId;

	if ($commentId > 0)
	{
		$commentItem = new Comment;
		$commentFields = array();

		if (isset($cachedFields[$commentId]))
		{
			$commentFields = $cachedFields[$commentId];
		}
		else
		{
			$select = array('*', 'UF_BLOG_COMM_URL_PRV');

			if (
				Option::get('disk', 'successfully_converted', false)
				&& ModuleManager::isModuleInstalled('disk')
			)
			{
				$select[] = 'UF_BLOG_COMMENT_FILE';
			}

			$res = CommentTable::getList(array(
				'filter' => array('=ID' => $commentId),
				'select' => $select
			));
			if ($fields = $res->fetch())
			{
				$commentFields = $fields;

				if ($commentFields['DATE_CREATE'] instanceof BitrixMainTypeDateTime)
				{
					$commentFields['DATE_CREATE'] = $commentFields['DATE_CREATE']->toString();
				}
			}

			$cachedFields[$commentId] = $commentFields;
		}

		$commentItem->setFields($commentFields);
	}

	return $commentItem;
}

Добавить комментарий