- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/scrum/controllers/dod.php
- Класс: BitrixTasksScrumControllersDoD
- Вызов: DoD::saveSettingsAction
public function saveSettingsAction(
int $typeId,
string $requiredOption,
array $items = [],
array $participants = []
): ?array
{
$userId = User::getId();
$typeService = new TypeService();
$entityService = new EntityService();
$type = $typeService->getType($typeId);
if ($type->isEmpty())
{
$this->errorCollection->setError(
new Error(
Loc::getMessage('TASKS_SDC_ERROR_TYPE_NOT_FOUND'),
self::ERROR_COULD_NOT_SAVE_SETTINGS
)
);
return null;
}
$entity = $entityService->getEntityById($type->getEntityId());
if (!Group::canReadGroupTasks($userId, $entity->getGroupId()))
{
$this->errorCollection->setError(
new Error(
Loc::getMessage('TASKS_SDC_ERROR_ACCESS_DENIED'),
self::ERROR_ACCESS_DENIED
)
);
return null;
}
$definitionOfDoneService = new DefinitionOfDoneService($userId);
$result = $definitionOfDoneService->mergeList(TypeChecklistFacade::class, $type->getId(), $items);
$result->setData(
array_merge(($result->getData() ?? []), ['OPEN_TIME' => (new DateTime())->getTimestamp()])
);
$typeForm = new TypeForm();
$typeForm->setId($type->getId());
$typeForm->setDodRequired($requiredOption);
if ($typeService->changeType($typeForm))
{
$typeForm->setParticipantsList($participants);
if ($type->getParticipantsCodes() !== $typeForm->getParticipantsCodes())
{
$typeService->saveParticipants($typeForm);
}
}
if ($result->isSuccess())
{
return [
'type' => $typeService->getType($type->getId())->toArray(),
];
}
else
{
$this->errorCollection->setError(
new Error(
'System error',
self::ERROR_COULD_NOT_SAVE_SETTINGS
)
);
return null;
}
}