Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Modules\Pdf\Domain\Repository;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11use App\Modules\Pdf\Domain\Model\PdfTemplate;
12use App\Modules\Pdf\Domain\Model\PdfTemplateVersion;
13
14/**
15 * Repository Contract for PDF Template Version Snapshots.
16 *
17 * @package App\Modules\Pdf\Domain\Repository
18 */
19interface PdfTemplateVersionRepositoryInterface
20{
21    /**
22     * Creates a new historical revision snapshot for the given template.
23     *
24     * @param PdfTemplate $template   Target template model.
25     * @param string|null $summary    Optional change summary description.
26     * @param int         $userId     Author user ID.
27     * @return PdfTemplateVersion Persisted version snapshot.
28     */
29    public function createVersion(PdfTemplate $template, ?string $summary = null, int $userId = 1): PdfTemplateVersion;
30
31    /**
32     * Lists all historical revision snapshots for the given template.
33     *
34     * @param int $templateId Parent template ID.
35     * @return array<int, PdfTemplateVersion> Historical snapshots ordered descending by version number.
36     */
37    public function findVersionsByTemplateId(int $templateId): array;
38
39    /**
40     * Finds a specific version snapshot by its primary identifier.
41     *
42     * @param int $versionId Version snapshot ID.
43     * @return PdfTemplateVersion|null Found snapshot or null.
44     */
45    public function findById(int $versionId): ?PdfTemplateVersion;
46
47    /**
48     * Restores a past revision snapshot back into the active template.
49     *
50     * @param int $templateId Target template ID.
51     * @param int $versionId  Version snapshot to restore.
52     * @param int $userId     User initiating the rollback.
53     * @return PdfTemplate Updated active template.
54     */
55    public function rollbackToVersion(int $templateId, int $versionId, int $userId = 1): PdfTemplate;
56}