• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/controller/onlyoffice.php
  • Класс: BitrixDiskControllerOnlyOffice
  • Вызов: OnlyOffice::loadDocumentEditorByViewSessionAction
public function loadDocumentEditorByViewSessionAction(ModelsDocumentSession $documentSession): ?HttpResponse
{
	if (!$documentSession->isView())
	{
		$this->addError(new Error('Could not work with session with {edit} type.'));

		return null;
	}

	if (!$documentSession->getObject())
	{
		$this->addError(new Error("Could not find file {{$documentSession->getObjectId()}}."));
		$documentSession->delete();

		return null;
	}

	if (!$documentSession->canTransformUserToEdit($this->getCurrentUser()))
	{
		$this->addError(new Error('Could not transform document session to edit mode because lack of rights.'));

		return null;
	}

	$createdSession = $documentSession->createEditSession();
	if (!$createdSession)
	{
		$this->addErrors($documentSession->getErrors());

		return null;
	}

	if ($createdSession->getId() != $documentSession->getId())
	{
		$documentSession->delete();
	}

	$documentSession = $createdSession;

	/** @see DiskFileEditorOnlyOfficeController::getSliderContentAction */
	$link = UrlManager::getInstance()->create('getSliderContent', [
		'c' => 'bitrix:disk.file.editor-onlyoffice',
		'mode' => Router::COMPONENT_MODE_AJAX,
		'documentSessionId' => $documentSession->getId(),
		'documentSessionHash' => $documentSession->getExternalHash(),
	]);

	return $this->redirectTo($link);
}