Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
common.php
1<?php
2namespace Bitrix\Pull;
3
4class Common
5{
6 public static function jsonEncode($params)
7 {
8 $option = JSON_UNESCAPED_UNICODE;
9 static::recursiveConvertDateToString($params);
10
11 return \Bitrix\Main\Web\Json::encode($params, $option);
12 }
13
14 public static function recursiveConvertDateToString(array &$params)
15 {
16 array_walk_recursive($params, function(&$item, $key){
17 if ($item instanceof \Bitrix\Main\Type\DateTime)
18 {
19 $item = date('c', $item->getTimestamp());
20 }
21 });
22 }
23
32 public static function findInvalidUnicodeSymbols(array $input, $currentPath = "")
33 {
34 if(!defined("BX_UTF"))
35 {
36 return false;
37 }
38
39 foreach ($input as $k => $v)
40 {
41 if(is_string($input[$k]))
42 {
43 if(!mb_check_encoding($input[$k]))
44 {
45 return $currentPath . "/" . $k;
46 }
47 }
48 else if (is_array($input[$k]))
49 {
50 $subResult = static::findInvalidUnicodeSymbols($input[$k], $currentPath . "/" . $k);
51 if($subResult)
52 {
53 return $subResult;
54 }
55 }
56 }
57
58 return false;
59 }
60}
static findInvalidUnicodeSymbols(array $input, $currentPath="")
Definition common.php:32
static jsonEncode($params)
Definition common.php:6
static recursiveConvertDateToString(array &$params)
Definition common.php:14