Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
userfieldassembler.php
1<?php
2
4
7use CSite;
8use CUser;
9
14{
15 private array $userCache = [];
16
26 protected function loadUserName(int $userId): string
27 {
28 $nameFormat = CSite::GetNameFormat();
29
30 $row = UserTable::getRow([
31 'select' => [
32 'ID',
33 'LOGIN',
34 'NAME',
35 'LAST_NAME',
36 'SECOND_NAME',
37 'EMAIL',
38 'TITLE',
39 ],
40 'filter' => [
41 '=ID' => $userId,
42 ],
43 ]);
44 if ($row)
45 {
46 return CUser::FormatName($nameFormat, $row, true, true);
47 }
48
49 return '';
50 }
51
59 private function getUserName(int $userId): ?string
60 {
61 if (!isset($this->userCache[$userId]))
62 {
63 $this->userCache[$userId] = $this->loadUserName($userId);
64 }
65
66 return $this->userCache[$userId];
67 }
68
74 protected function prepareColumn($value)
75 {
76 if (isset($value) && is_numeric($value))
77 {
78 $value = (int)$value;
79 if ($value > 0)
80 {
81 return $this->getUserName($value);
82 }
83 }
84
85 return null;
86 }
87}
static getRow(array $parameters)