38 public function register(array $fields):
Result
40 if (isset($fields[
'subject_id']))
42 $fields[InternalOption::SENDER_ID] = $fields[
'subject_id'];
45 if (!isset($fields[InternalOption::API_KEY], $fields[InternalOption::SENDER_ID]))
49 $this->optionManager->setOption(InternalOption::API_KEY, (
string)$fields[InternalOption::API_KEY]);
52 foreach (explode(
';', (
string)$fields[InternalOption::SENDER_ID]) as $senderId)
54 $senderId = trim($senderId);
57 $subjectIdList[] = (int)$senderId;
60 if (!$this->utils->checkActiveChannelBySubjectIdList($subjectIdList, $this->channelType))
62 $this->optionManager->clearOptions();
67 foreach ($subjectIdList as $subjectId)
69 $setCallbackResult = $this->utils->setCallback(
74 if (!$setCallbackResult->isSuccess())
76 $this->optionManager->clearOptions();
78 $errorData = $setCallbackResult->getData();
80 if (isset($errorData[
'detail']))
82 return (
new Result())->addError(
new Error($errorData[
'detail']));
85 return $setCallbackResult;
89 $this->optionManager->setOption(InternalOption::SENDER_ID, $subjectIdList);
90 $this->optionManager->setOption(InternalOption::MIGRATED_TO_STANDART_SETTING_NAMES,
'Y');