• Модуль: disk
  • Путь к файлу: ~/bitrix/modules/disk/lib/document/onlyoffice/documentsessionmanager.php
  • Класс: BitrixDiskDocumentOnlyOfficeDocumentSessionManager
  • Вызов: DocumentSessionManager::findOrCreateSession
public function findOrCreateSession(): ?ModelsDocumentSession
{
	$session = $this->findSession() ?: $this->addSession();
	if (!$session)
	{
		return null;
	}

	if ($session->isView() && $session->isOutdatedByFileContent())
	{
		$session = $this->addSession();
		if (!$session)
		{
			return null;
		}
	}

	if (!$session->belongsToUser($this->getUserId()))
	{
		$fork = $session->forkForUser($this->getUserId(), $this->sessionContext);
		if (!$fork)
		{
			$this->errorCollection->add($session->getErrors());
		}

		return $fork;
	}

	if ($session->isNonActive())
	{
		return $session->cloneWithNewHash($this->getUserId(), $this->sessionContext);
	}

	return $session;
}