- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/integration/landing/formlanding.php
- Класс: Bitrix\Crm\Integration\Landing\FormLanding
- Вызов: FormLanding::createLanding
public function createLanding($formId, $formName = null): ?int
{
$siteId = $this->getSiteId();
if (!$siteId)
{
return $siteId;
}
if (!$formId)
{
return null;
}
Rights::setGlobalOff();
$result = Landing::add([
'TITLE' => $formName ?: 'CRM Form',
'SITE_ID' => $siteId,
'CODE' => self::LANDING_CODE_PRERIX . mb_strtolower(\Bitrix\Main\Security\Random::getString(5, true))
]);
if ($result->isSuccess())
{
$lid = $result->getId();
$landing = Landing::createInstance($lid);
$blockId = $landing->addBlock('66.90.form_new_default', [
'ACCESS' => 'W'
]);
if ($blockId)
{
Subtype\Form::setFormIdToBlock($blockId, $formId);
}
$webpack = Webpack\Form::instance($formId);
if (!$webpack->getEmbeddedFileUrl())
{
Agent::addUniqueAgent('rePublicationLanding', [$lid], 7200, 60);
}
Rights::setGlobalOn();
return $lid;
}
Rights::setGlobalOn();
$this->setErrorMessage($result->getErrors()[0]);
return null;
}