Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
settings.php
1<?php
2
4
6
8{
9 private string $category;
10
11 public function __construct(string $category)
12 {
13 $this->category = $category;
14 }
15
19 public function get()
20 {
21 $settings = \CUserOptions::GetOption($this->category, 'activity_settings');
22 if (is_array($settings) || is_string($settings))
23 {
24 static::decodeSettings($settings);
25 }
26 else
27 {
28 $settings = null;
29 }
30
31 return $settings;
32 }
33
38 public function save($settings): void
39 {
40 static::encodeSettings($settings);
41 \CUserOptions::SetOption($this->category, 'activity_settings', $settings);
42 }
43
48 public static function decodeSettings(&$settings): void
49 {
50 if (is_array($settings))
51 {
52 array_walk_recursive(
53 $settings,
54 function (&$value) {
55 if (is_string($value))
56 {
57 $value = Emoji::decode($value);
58 }
59 }
60 );
61 }
62 elseif (is_string($settings))
63 {
64 Emoji::decode($settings);
65 }
66 }
67
72 public static function encodeSettings(&$settings): void
73 {
74 if (is_array($settings))
75 {
76 array_walk_recursive(
77 $settings,
78 function (&$value) {
79 if (is_string($value))
80 {
81 $value = Emoji::encode($value);
82 }
83 }
84 );
85 }
86 elseif (is_string($settings))
87 {
88 $settings = Emoji::encode($settings);
89 }
90 }
91}
static encodeSettings(&$settings)
Definition settings.php:72
__construct(string $category)
Definition settings.php:11
static decodeSettings(&$settings)
Definition settings.php:48
static encode($text)
Definition emoji.php:17
static decode($text)
Definition emoji.php:24