30 $templatesResult = $this->utils->getMessageTemplates();
31 if (!$templatesResult->isSuccess())
36 $templates = $templatesResult->getData();
37 if (!is_array($templates))
43 $placeholderEnabled = \Bitrix\Main\Config\Option::get(
'messageservice',
'template_placeholders_enabled',
'N') ===
'Y';
46 foreach ($templates as $template)
50 if (!empty($template[
'placeholders']) && !$placeholderEnabled)
56 'ID' => Json::encode($template[
'content']),
57 'TITLE' => $template[
'name'],
58 'PREVIEW' => $template[
'content'][
'text'] ??
'',
61 if (!empty($template[
'content'][
'header'][
'text']))
63 $tmp[
'HEADER'] = $template[
'content'][
'header'][
'text'];
65 if (!empty($template[
'content'][
'footer'][
'text']))
67 $tmp[
'FOOTER'] = $template[
'content'][
'footer'][
'text'];
69 if (!empty($template[
'content'][
'keyboard'][
'rows']))
71 $tmp[
'KEYBOARD'] = $template[
'content'][
'keyboard'];
73 if (!empty($template[
'placeholders']))
75 $tmp[
'PLACEHOLDERS'] = [];
77 if (!empty($template[
'placeholders'][
'text']))
79 $tmp[
'PLACEHOLDERS'][
'PREVIEW'] = $template[
'placeholders'][
'text'];
81 if (!empty($template[
'placeholders'][
'header']))
83 $tmp[
'PLACEHOLDERS'][
'HEADER'] = $template[
'placeholders'][
'header'];
85 if (!empty($template[
'placeholders'][
'footer']))
87 $tmp[
'PLACEHOLDERS'][
'FOOTER'] = $template[
'placeholders'][
'footer'];