Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
abstractaudiencestatusnormalizer.php
1<?php
2
4
6
8{
9 protected const AUDIENCE_TYPE_CODE = '';
10
11 public const NORMALIZED_STATUS_READY = 'READY';
12 public const NORMALIZED_STATUS_PROCESSING = 'PROCESSING';
13 public const NORMALIZED_STATUS_OTHER = 'OTHER';
14
15 protected array $originalStatusToNormalizedMap = [];
16
23 public function getNormalizedStatus(?string $originalStatus): string
24 {
25 if ($originalStatus === null)
26 {
28 }
29
30 return $this->originalStatusToNormalizedMap[$originalStatus] ?? self::NORMALIZED_STATUS_PROCESSING;
31 }
32
38 public function getNormalizedStatusTranslation(?string $originalStatus): string
39 {
40 $normalizedStatus = $this->getNormalizedStatus($originalStatus);
41
42 if (in_array($normalizedStatus, [self::NORMALIZED_STATUS_READY, self::NORMALIZED_STATUS_PROCESSING], true))
43 {
44 return $this->getDefaultNormalizedStatusesTranslation($normalizedStatus);
45 }
46
47 return Loc::getMessage($this->getNormalizedStatusTranslationKey($originalStatus));
48 }
49
50 protected function getNormalizedStatusTranslationKey(string $originalStatus): string
51 {
52 $translationKeyPrefix = 'SEO_RETARGETING_SERVICE_AUDIENCE_STATUS_';
53 $audienceTypeCodePrefix = strtoupper(static::AUDIENCE_TYPE_CODE) . '_';
54 $originalStatusPostfix = strtoupper($originalStatus);
55
56 return $translationKeyPrefix . $audienceTypeCodePrefix . $originalStatusPostfix;
57 }
58
63 protected function getDefaultNormalizedStatusesTranslation(string $status): string
64 {
65 return Loc::getMessage('SEO_RETARGETING_SERVICE_AUDIENCE_STATUS_DEFAULT_' . $status);
66 }
67}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29