• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/classes/general/commentitem.php
  • Класс: CTaskCommentItem
  • Вызов: CTaskCommentItem::runRestMethod
static function runRestMethod($executiveUserId, $methodName, $args,
	/** @noinspection PhpUnusedParameterInspection */ $navigation)
{
	static $arManifest = null;
	static $arMethodsMetaInfo = null;

	if ($arManifest === null)
	{
		$arManifest = self::getManifest();
		$arMethodsMetaInfo = $arManifest['REST: available methods'];
	}

	// Check and parse params
	CTaskAssert::assert(isset($arMethodsMetaInfo[$methodName]));
	$arMethodMetaInfo = $arMethodsMetaInfo[$methodName];
	$argsParsed = CTaskRestService::_parseRestParams('ctaskcommentitem', $methodName, $args);

	$returnValue = null;
	if (isset($arMethodMetaInfo['staticMethod']) && $arMethodMetaInfo['staticMethod'])
	{
		if ($methodName === 'add')
		{
			[$taskId, $arFields] = $argsParsed;
			$task = CTaskItem::getInstance($taskId, $executiveUserId);
			$itemId = self::add($task, $arFields);

			$returnValue = $itemId;
		}
		elseif ($methodName === 'getlist')
		{
			$taskId = $argsParsed[0];
			$task = CTaskItem::getInstance($taskId, $executiveUserId);
			$order = (is_array($argsParsed[1]) ? $argsParsed[1] : []);
			$filter = (is_array($argsParsed[2]) ? $argsParsed[2] : []);

			[$commentItems, ] = self::fetchList($task, $order, $filter);

			$returnValue = [];
			foreach ($commentItems as $commentItem)
			{
				$returnValue[] = $commentItem->getData(false);
			}
		}
		else
		{
			$returnValue = call_user_func_array(['self', $methodName], $argsParsed);
		}
	}
	else
	{
		$taskId = array_shift($argsParsed);
		$itemId = array_shift($argsParsed);
		$task = CTaskItem::getInstance($taskId, $executiveUserId);
		$comment = new self($task, $itemId);

		if ($methodName === 'get')
		{
			CTaskAssert::assert(MainLoader::includeModule('disk'));
			CTaskAssert::assert(MainLoader::includeModule('forum'));
			CTaskAssert::assert(MainLoader::includeModule('socialnetwork'));

			$returnValue = $comment->getData(false);
			$returnValue = static::parseCommentPostMessage($returnValue);
			$returnValue = static::getCommentAttachmentIds($returnValue);
		}
		else
		{
			$returnValue = call_user_func_array([$comment, $methodName], $argsParsed);
		}
	}

	return [$returnValue, null];
}