1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Group.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\V2\Controller\Notify;
4
5use Bitrix\Im\V2\Controller\BaseController;
6use Bitrix\Im\V2\Controller\Filter\CheckNotifyGroupAccess;
7use Bitrix\Im\V2\Notification\Group\UserGroup\Dto\UpdateGroupDto;
8use Bitrix\Im\V2\Notification\Group\UserGroup\Dto\UserGroupDto;
9use Bitrix\Im\V2\Notification\Group\GroupItemFactory;
10use Bitrix\Im\V2\Notification\Group\UserGroup\Dto\CreateGroupDto;
11use Bitrix\Im\V2\Notification\Group\UserGroup\GroupRepository;
12use Bitrix\Main\Engine\AutoWire\BinderArgumentException;
13use Bitrix\Main\Engine\AutoWire\ExactParameter;
14use Bitrix\Main\Engine\CurrentUser;
15use Bitrix\Main\Request;
16
17class Group extends BaseController
18{
19 private readonly GroupRepository $groupRepository;
20
21 public function __construct(Request $request = null)
22 {
23 parent::__construct($request);
24 $this->groupRepository = new GroupRepository();
25 }
26
30 public function getAutoWiredParameters(): array
31 {
32 return [
34 UserGroupDto::class,
35 'userGroup',
36 function(string $className, int $groupId): UserGroupDto
37 {
38 return new UserGroupDto($groupId, (int)CurrentUser::get()?->getId());
39 }
40 ),
41 ];
42 }
43
44 protected function getDefaultPreFilters(): array
45 {
46 return array_merge(
47 parent::getDefaultPreFilters(),
48 [
50 ]
51 );
52 }
53
54 public function addAction(string $title, string $module, string $event): ?array
55 {
56 $createDto = new CreateGroupDto(
58 userId: (int)CurrentUser::get()?->getId(),
59 module: $module,
60 event: $event,
61 );
62
63 $result = $this->groupRepository->create($createDto);
64 if ($result->isSuccess())
65 {
66 return [
67 'id' => $result->id,
68 ];
69 }
70
71 $this->addErrors($result->getErrors());
72
73 return null;
74 }
75
76 public function listAction(): array
77 {
78 return [
79 'items' => (new GroupItemFactory())->makeForCurrentContextUser()->toRestFormat(),
80 ];
81 }
82
83 public function deleteAction(UserGroupDto $userGroup): array
84 {
85 $this->groupRepository->deleteById($userGroup->groupId);
86
87 return ['result' => true];
88 }
89
90 public function updateAction(UserGroupDto $userGroup, string $title): ?array
91 {
92 $updateDto = new UpdateGroupDto(
94 groupId: $userGroup->groupId,
95 );
96 $result = $this->groupRepository->update($updateDto);
97 if ($result->isSuccess())
98 {
99 return ['result' => true];
100 }
101
102 $this->addErrors($result->getErrors());
103
104 return null;
105 }
106}
if(!Loader::includeModule('catalog')) if(!AccessController::getCurrent() ->check(ActionDictionary::ACTION_PRICE_EDIT)) if(!check_bitrix_sessid()) $request
Определения catalog_reindex.php:36
addAction(string $title, string $module, string $event)
Определения Group.php:54
__construct(Request $request=null)
Определения Group.php:21
deleteAction(UserGroupDto $userGroup)
Определения Group.php:83
updateAction(UserGroupDto $userGroup, string $title)
Определения Group.php:90
Определения request.php:10
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
$event
Определения prolog_after.php:141
<? endif;?> window document title
Определения prolog_main_admin.php:76
$title
Определения pdf.php:123