• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/controller/ads/leadads/form.php
  • Класс: Bitrix\Crm\Controller\Ads\LeadAds\Form
  • Вызов: Form::listAction
public function listAction(string $type, $accountId, $proxyId = null): AjaxJson
{
	if (!$service = $this->getService($proxyId))
	{
		$this->addError(
			new Error("Service not available.")
		);

		return $this->errorResponse();
	}

	if (!$form = $service->getForm($type))
	{
		$this->addError(
			new Error("Wrong type {$type}.")
		);

		return $this->errorResponse();
	}

	if ((int)$accountId !== 0)
	{
		$form->setAccountId($accountId);
	}
	$formListResponse = $form->getList();

	if (!$formListResponse->isSuccess())
	{
		$this->addErrors(
			$formListResponse->getErrors()
		);

		return $this->errorResponse();
	}

	/**@var Form[] $result*/
	for($result = [];$form = $formListResponse->fetch();)
	{
		if ($form->isActive())
		{
			$result[] = $form;
		}
	}


	return $this->successResponse([
		"forms" => $result
	]);

}