28 protected function init(): void
32 $this->userId = (int)CurrentUser::get()->getId();
33 $this->accessController = CollabAccessController::getInstance($this->userId);
34 $this->collabController =
new Collab();
41 ConvertToCollabDto::class,
54 'convertToCollab' => [
62 public function validateGroupAction(
int $id): ?
array
64 if (!ConverterFeature::isOn())
66 $this->addError(
new Error(
'Feature is not available'));
74 $this->addError(
new Error(
'Group not found'));
79 if (!GroupAccessController::can($this->userId, GroupDictionary::CONVERT, $id))
81 $this->addError(
new Error(
'Access denied'));
87 $command = (
new ConvertToCollabCommand())
89 ->setInitiatorId($this->userId)
92 $validationResult = $command->validateGroup();
94 if (!$validationResult->isSuccess())
96 $this->addErrors($validationResult->getErrors());
100 'isValid' => $validationResult->isSuccess(),
107 public function convertToCollabAction(ConvertToCollabDto $dto): ?\Bitrix\Socialnetwork\
Collab\
Collab
109 if (!ConverterFeature::isOn())
117 if (!($group instanceof Workgroup))
124 if (!GroupAccessController::can($this->userId, GroupDictionary::CONVERT, $dto->id))
131 $command = (
new ConvertToCollabCommand())
133 ->setInitiatorId($this->userId)
136 $service = ServiceLocator::getInstance()->get(
'socialnetwork.collab.converter.service');
138 $converterResult =
$service->convert($command);
140 if (!$converterResult->isSuccess())
142 $this->
addErrors($converterResult->getErrors());
147 $getDto =
new CollabGetDto($converterResult->getEntityAfter()->getId());
149 return $this->collabController->getAction($getDto);