mirror of
https://github.com/LibreSign/libresign.git
synced 2025-12-18 05:20:45 +01:00
feat: add FileStatusService for file status operations
Created dedicated service to handle file status management. Includes updateFileStatusIfUpgrade to upgrade file status and canNotifySigners to validate if file status allows notifications. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
This commit is contained in:
parent
e784c39bcb
commit
ecc8a6a2f1
1 changed files with 32 additions and 0 deletions
32
lib/Service/FileStatusService.php
Normal file
32
lib/Service/FileStatusService.php
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace OCA\Libresign\Service;
|
||||
|
||||
use OCA\Libresign\Db\File as FileEntity;
|
||||
use OCA\Libresign\Db\FileMapper;
|
||||
|
||||
class FileStatusService {
|
||||
public function __construct(
|
||||
private FileMapper $fileMapper,
|
||||
) {
|
||||
}
|
||||
|
||||
public function updateFileStatusIfUpgrade(FileEntity $file, int $newStatus): FileEntity {
|
||||
$currentStatus = $file->getStatus();
|
||||
if ($newStatus > $currentStatus) {
|
||||
$file->setStatus($newStatus);
|
||||
$this->fileMapper->update($file);
|
||||
}
|
||||
return $file;
|
||||
}
|
||||
|
||||
public function canNotifySigners(?int $fileStatus): bool {
|
||||
return $fileStatus === FileEntity::STATUS_ABLE_TO_SIGN;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue