mirror of
https://github.com/LibreSign/libresign.git
synced 2025-12-18 05:20:45 +01:00
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>
32 lines
743 B
PHP
32 lines
743 B
PHP
<?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;
|
|
}
|
|
}
|