• Модуль: salescenter
  • Путь к файлу: ~/bitrix/modules/salescenter/lib/integration/landingmanager.php
  • Класс: BitrixSalesCenterIntegrationLandingManager
  • Вызов: LandingManager::createWebFormLanding
public function createWebFormLanding($formId, $isPublic = false)
{
	$result = new Result();
	if(!$this->isSiteExists())
	{
		return $result->addError(new Error('Site is not found'));
	}
	$component = $this->getLandingDemoComponent();
	if(!$component)
	{
		return $result->addError(new Error('Landing demo component is not found'));
	}
	$webFormPageCode = $this->getWebFormPageCode($component);
	if(!$webFormPageCode)
	{
		return $result->addError(new Error('Landing template for web form is not found'));
	}
	// todo replace this with runtime event
	$previousWebFormPage = $this->getLastCreatedWebFormLanding($webFormPageCode);
	$component->actionSelect($webFormPageCode);
	$lastWebFormPage = $this->getLastCreatedWebFormLanding($webFormPageCode);
	if(($lastWebFormPage && !$previousWebFormPage) || $lastWebFormPage['ID'] > $previousWebFormPage['ID'])
	{
		$landingId = $lastWebFormPage['ID'];
		$result->setData(['landingId' => $landingId]);
		$setResult = $this->setPageWebFormId($landingId, $formId);
		if($setResult->isSuccess())
		{
			$updateResult = $this->setLandingPageConnection($landingId, $formId);
			if($updateResult->isSuccess())
			{
				$result->setData(array_merge($result->getData(), ['pageId' => $updateResult->getId()]));
				if($isPublic)
				{
					$landing = LandingLanding::createInstance($landingId);
					$landing->publication();
					if(!$landing->getError()->isEmpty())
					{
						$result->addErrors($landing->getError()->getErrors());
					}
				}
			}
			else
			{
				$result->addErrors($updateResult->getErrors());
			}
		}
		else
		{
			LandingLanding::delete($landingId);
			$result->addErrors($setResult->getErrors());
		}
	}
	else
	{
		$result->addError(new Error('Could not create web form page'));
	}

	return $result;
}