Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
User.php
1<?php
2
4
7
8class User extends BaseController
9{
11 {
12 return new ExactParameter(
14 'user',
15 function ($className, int $id) {
16 return $this->getUserById($id);
17 }
18 );
19 }
20
24 public function getDepartmentAction(Entity\User\User $user): ?array
25 {
26 $department = $user->getDepartments()->filterExist()->getDeepest()->getAny();
27
28 if ($department === null)
29 {
30 return null;
31 }
32
33 return $this->toRestFormat($department);
34 }
35
36 protected function getUserById(int $id): ?Entity\User\User
37 {
38 $user = Entity\User\User::getInstance($id);
39
40 if (!$user->isExist())
41 {
42 $this->addError(new Entity\User\UserError(Entity\User\UserError::NOT_FOUND));
43
44 return null;
45 }
46
47 return $user;
48 }
49}
toRestFormat(RestConvertible ... $entities)
getDepartmentAction(Entity\User\User $user)
Definition User.php:24