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;
12
13/**
14 * Domain Repository Contract for PDF Templates.
15 *
16 * @package App\Modules\Pdf\Domain\Repository
17 */
18interface PdfTemplateRepositoryInterface
19{
20    /**
21     * Finds a PDF template by its primary key ID.
22     *
23     * @param int $id Template identifier.
24     * @return PdfTemplate|null Template model or null if not found.
25     */
26    public function findById(int $id): ?PdfTemplate;
27
28    /**
29     * Finds an active PDF template by its machine code and language.
30     *
31     * @param string $code         Unique template code.
32     * @param string $languageCode Locale code.
33     * @return PdfTemplate|null Matching active template or null.
34     */
35    public function findByCode(string $code, string $languageCode = 'pl'): ?PdfTemplate;
36
37    /**
38     * Finds all active PDF templates applicable to a given module.
39     *
40     * @param string $moduleName   Module name or 'global'.
41     * @param string $languageCode Locale code.
42     * @return array<int, PdfTemplate> List of active templates.
43     */
44    public function findAllActiveByModule(string $moduleName, string $languageCode = 'pl'): array;
45
46    /**
47     * Persists or updates a PDF template record.
48     *
49     * @param PdfTemplate $template Aggregate to persist.
50     * @return int Primary key ID of saved record.
51     */
52    public function save(PdfTemplate $template): int;
53
54    /**
55     * Marks template as deleted or archives record.
56     *
57     * @param int $id Primary ID.
58     * @return bool True on successful deletion.
59     */
60    public function delete(int $id): bool;
61}