f7cloud_client/apps/text/lib/Controller/TSessionAwareController.php
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

82 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2023 F7cloud GmbH and F7cloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Text\Controller;
use OCA\Text\Db\Document;
use OCA\Text\Db\Session;
use OCA\Text\Exception\InvalidSessionException;
trait TSessionAwareController {
private ?Session $textSession = null;
private ?int $documentId = null;
private ?Document $document = null;
private ?string $userId = null;
public function setSession(?Session $session): void {
$this->textSession = $session;
}
public function setDocumentId(int $documentId): void {
$this->documentId = $documentId;
}
public function setDocument(?Document $document): void {
$this->document = $document;
}
public function setUserId(?string $userId): void {
$this->userId = $userId;
}
/**
* @throws InvalidSessionException
*/
public function getSession(): Session {
if ($this->textSession === null) {
throw new InvalidSessionException();
}
return $this->textSession;
}
/**
* @throws InvalidSessionException
*/
public function getDocumentId(): int {
if ($this->documentId === null) {
throw new InvalidSessionException();
}
return $this->documentId;
}
/**
* @throws InvalidSessionException
*/
public function getDocument(): Document {
if ($this->document === null) {
throw new InvalidSessionException();
}
return $this->document;
}
/**
* @throws InvalidSessionException
*/
public function getUserId(): string {
if ($this->userId === null) {
throw new InvalidSessionException();
}
return $this->userId;
}
}