Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
author.php
1<?php
2
4
5class Author
6{
7 private int $userId;
8 private array $user;
9
10 public function __construct(int $userId)
11 {
12 $this->userId = $userId;
13 $this->init();
14 }
15
16 public function getName(): string
17 {
18 return trim("{$this->user['NAME']} {$this->user['LAST_NAME']}");
19 }
20
21 public function getWorkPosition(): string
22 {
23 return (string)$this->user['WORK_POSITION'];
24 }
25
26 public function toMeta(): array
27 {
28 return [
29 'author' => [
30 'name' => $this->getName(),
31 'work_position' => $this->getWorkPosition(),
32 ],
33 ];
34 }
35
36 private function init(): void
37 {
38 $this->user = \CUser::GetByID($this->userId)->Fetch();
39 }
40}