Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
userfieldassembler.php
1
<?php
2
3
namespace
Bitrix\Main\Grid\Row\Assembler\Field
;
4
5
use
Bitrix\Main\Grid\Row\FieldAssembler
;
6
use
Bitrix\Main\UserTable
;
7
use CSite;
8
use CUser;
9
13
class
UserFieldAssembler
extends
FieldAssembler
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
}
Bitrix\Main\Grid\Row\Assembler\Field\UserFieldAssembler
Definition
userfieldassembler.php:14
Bitrix\Main\Grid\Row\Assembler\Field\UserFieldAssembler\prepareColumn
prepareColumn($value)
Definition
userfieldassembler.php:74
Bitrix\Main\Grid\Row\Assembler\Field\UserFieldAssembler\loadUserName
loadUserName(int $userId)
Definition
userfieldassembler.php:26
Bitrix\Main\Grid\Row\FieldAssembler
Definition
fieldassembler.php:22
Bitrix\Main\ORM\Data\DataManager\getRow
static getRow(array $parameters)
Definition
datamanager.php:410
Bitrix\Main\UserTable
Definition
user.php:46
Bitrix\Main\Grid\Row\Assembler\Field
Definition
listfieldassembler.php:3
modules
main
lib
grid
row
assembler
field
userfieldassembler.php
Создано системой
1.10.0