1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
AbstractMemberService.php
См. документацию.
1<?php
2
4
11use Bitrix\Socialnetwork\Control\Member\Trait\GetMembersTrait;
14use Psr\Container\NotFoundExceptionInterface;
15
17{
18 use GetMembersTrait;
19
21
26 public function __construct()
27 {
28 $this->validationService = ServiceLocator::getInstance()->get('main.validation.service');
29 }
30
31 abstract protected function inviteImplementation(MembersCommand $command, Workgroup $group): Result;
32
33 abstract protected function addImplementation(MembersCommand $command, Workgroup $group): Result;
34
35 abstract protected function deleteImplementation(MembersCommand $command, Workgroup $group): Result;
36
37 abstract protected function addModeratorsImplementation(MembersCommand $command, Workgroup $group): Result;
38
39 abstract protected function deleteModeratorsImplementation(MembersCommand $command, Workgroup $group): Result;
40
41 abstract protected function getRegistry(): GroupRegistry;
42
43 public function invite(MembersCommand $command): Result
44 {
45 $validationResult = $this->validationService->validate($command);
46 if (!$validationResult->isSuccess())
47 {
48 return $validationResult;
49 }
50
51 $result = new Result();
52
53 $group = $this->getRegistry()->get($command->getGroupId());
54 if ($group === null)
55 {
56 $result->addError(new Error('No such group'));
57
58 return $result;
59 }
60
61 return $this->inviteImplementation($command, $group);
62 }
63
64 public function add(MembersCommand $command): Result
65 {
66 $validationResult = $this->validationService->validate($command);
67 if (!$validationResult->isSuccess())
68 {
69 return $validationResult;
70 }
71
72 $result = new Result();
73
74 $group = $this->getRegistry()->get($command->getGroupId());
75 if ($group === null)
76 {
77 $result->addError(new Error('No such group'));
78
79 return $result;
80 }
81
82 return $this->addImplementation($command, $group);
83 }
84
85 public function delete(MembersCommand $command): Result
86 {
87 $validationResult = $this->validationService->validate($command);
88 if (!$validationResult->isSuccess())
89 {
90 return $validationResult;
91 }
92
93 $result = new Result();
94
95 $group = $this->getRegistry()->get($command->getGroupId());
96 if ($group === null)
97 {
98 $result->addError(new Error('No such group'));
99
100 return $result;
101 }
102
103 return $this->deleteImplementation($command, $group);
104 }
105
106 public function addModerators(MembersCommand $command): Result
107 {
108 $result = new Result();
109
110 $validationResult = $this->validationService->validate($command);
111 if (!$validationResult->isSuccess())
112 {
113 return $validationResult;
114 }
115
116 $group = $this->getRegistry()->get($command->getGroupId());
117 if ($group === null)
118 {
119 $result->addError(new Error('No such group'));
120
121 return $result;
122 }
123
124 return $this->addModeratorsImplementation($command, $group);
125 }
126
127 public function deleteModerators(MembersCommand $command): Result
128 {
129 $result = new Result();
130
131 $validationResult = $this->validationService->validate($command);
132 if (!$validationResult->isSuccess())
133 {
134 return $validationResult;
135 }
136
137 $group = $this->getRegistry()->get($command->getGroupId());
138 if ($group === null)
139 {
140 $result->addError(new Error('No such group'));
141
142 return $result;
143 }
144
145 return $this->deleteModeratorsImplementation($command, $group);
146 }
147
148}
Определения error.php:15
inviteImplementation(MembersCommand $command, Workgroup $group)
addModeratorsImplementation(MembersCommand $command, Workgroup $group)
addImplementation(MembersCommand $command, Workgroup $group)
deleteImplementation(MembersCommand $command, Workgroup $group)
deleteModeratorsImplementation(MembersCommand $command, Workgroup $group)
$result
Определения get_property_values.php:14