17 private const EMPTY_FIELD_NAME =
null;
24 $this->mapper = $mapper;
35 $fields = $this->buildFields($form[
'CONTACT_FIELDS'] ?? []);
36 $questions = $this->buildQuestions($form[
'PAGES'] ?? []);
40 "name" => $form[
'NAME'],
42 "title" => $form[
'NAME'],
43 "fields" => array_merge($fields, $questions)
55 private function buildFields(array $questions) : array
57 foreach ($questions as $key => $externalField)
59 if ($fieldName = $this->mapper->getCrmName($externalField))
63 self::EMPTY_FIELD_NAME,
64 $this->getFormLabel($fieldName),
70 unset($questions[$key]);
81 private function getFormLabel(
string $type) : string
83 if (!$phrase =
Loc::getMessage(
"SEO_VKONTAKTE_FORM_BUILDER_TYPE_{$type}"))
91 private function buildQuestions(array $pages)
94 foreach ($pages as $page)
96 if ( ! (isset($page[
'blocks']) && is_array($page[
'blocks'])))
101 foreach ($page[
'blocks'] as $block)
104 ! (isset($block[
'block_data']) && is_array($block[
'block_data']))
105 && $block[
'type'] !== self::PAGE_TYPE_QUESTION
106 && ! (isset($block[
'block_data'][
'data']) && is_array($block[
'block_data'][
'data']))
113 if ($fieldName = $this->mapper->getCrmName(self::PAGE_TYPE_QUESTION))
115 $result[] =
new LeadAds\Field(
117 self::EMPTY_FIELD_NAME,
118 $block[
'block_data'][
'data'][
'text'],
static loadMessages($file)
static getMessage($code, $replace=null, $language=null)