Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
configcomponent.php
1<?php
2
4
9
10abstract class ConfigComponent extends \CBitrixComponent
11{
12 public const ERROR_CODE_NO_MODULE_ERROR = 'UF_CONFIG_NO_MODULE';
13
15 protected $access;
16 protected $entityId = '';
17 protected $moduleId;
20 protected $userTypes;
21
22 protected function init(): void
23 {
24 $this->errorCollection = new ErrorCollection();
25
26 $request = Application::getInstance()->getContext()->getRequest();
27 $this->entityId = !empty($this->arParams['entityId']) ? $this->arParams['entityId'] : $request->get('entityId');
28 $this->moduleId = !empty($this->arParams['moduleId']) ? $this->arParams['moduleId'] : $request->get('moduleId');
29
30 if(!$this->moduleId)
31 {
32 $this->errorCollection[] = $this->getNoModuleError();
33 return;
34 }
35 $this->access = UserFieldAccess::getInstance($this->moduleId);
36 }
37
38 protected function getNoModuleError(): Error
39 {
40 return new Error(Loc::getMessage('MAIN_USER_FIELD_CONFIG_COMPONENT_NO_MODULE_ERROR'), static::ERROR_CODE_NO_MODULE_ERROR);
41 }
42
43 protected function getAccessDeniedError(): Error
44 {
45 return new Error(Loc::getMessage('MAIN_USER_FIELD_CONFIG_COMPONENT_ACCESS_DENIED_ERROR'), static::ERROR_CODE_NO_MODULE_ERROR);
46 }
47
48 protected function getUserTypes(): array
49 {
50 if(!$this->userTypes)
51 {
52 global $USER_FIELD_MANAGER;
53 $this->userTypes = $USER_FIELD_MANAGER->GetUserType();
54 $restrictedTypes = $this->access->getRestrictedTypes();
55 foreach($restrictedTypes as $typeId)
56 {
57 unset($this->userTypes[$typeId]);
58 }
59 }
60
61 return $this->userTypes;
62 }
63
64 protected function setTitle(string $title): void
65 {
66 global $APPLICATION;
67
68 $APPLICATION->SetTitle($title);
69 }
70}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getInstance(string $moduleId, int $userId=null)