Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
standartbuilder.php
1<?php
2
4
6
8{
12 public function setOutput(): void
13 {
14 if ($this->resources->isEmpty())
15 {
16 return;
17 }
18
19 $this->normalizeResources();
20 $this->initResourcesAsJsExtension($this->normalizedResources);
21
22 $this->setStrings();
23 }
24
25 protected function normalizeResources(): void
26 {
27 $this->normalizedResources = $this->resources->getNormalized();
29 }
30
31 protected function normalizeLangResources(): void
32 {
33 $langResources = $this->normalizedResources[Types::TYPE_LANG] ?? null;
34 if (isset($langResources) && !empty($langResources))
35 {
36 // convert array to string (get first element)
37 $this->normalizedResources[Types::TYPE_LANG] = $this->normalizedResources[Types::TYPE_LANG][0];
38
39 // other files load by additional lang
40 if ($additionalLang = self::loadAdditionalLangPhrases(array_slice($langResources, 1)))
41 {
42 $this->normalizedResources[Types::TYPE_LANG_ADDITIONAL] = $additionalLang;
43 }
44 }
45 }
46
47 protected static function loadAdditionalLangPhrases(array $langResources): array
48 {
49 $additionalLangPhrases = [];
50 foreach ($langResources as $file)
51 {
52 foreach (Loc::loadLanguageFile($_SERVER['DOCUMENT_ROOT'] . $file) as $key => $phrase)
53 {
54 $additionalLangPhrases[$key] = $phrase;
55 }
56 }
57
58 return $additionalLangPhrases;
59 }
60}
initResourcesAsJsExtension(array $resources, $extName=null)
Definition builder.php:87
static loadAdditionalLangPhrases(array $langResources)
static loadLanguageFile($file, $language=null, $normalize=true)
Definition loc.php:224