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\Structure\Domain\Repository;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11use App\Modules\Structure\Domain\Model\StructureNode;
12
13/**
14 * Structure Repository Domain Contract.
15 *
16 * Provides persistence abstraction for organizational structure nodes.
17 *
18 * @package App\Modules\Structure\Domain\Repository
19 */
20interface StructureRepositoryInterface
21{
22    /**
23     * Finds structure node by primary ID.
24     *
25     * @param int $id Node ID.
26     * @return StructureNode|null Node entity or null if not found.
27     */
28    public function findById(int $id): ?StructureNode;
29
30    /**
31     * Finds structure node by unique code identifier.
32     *
33     * @param string $code Node unique code.
34     * @return StructureNode|null Node entity or null if not found.
35     */
36    public function findByCode(string $code): ?StructureNode;
37
38    /**
39     * Retrieves all active structure nodes as flat list.
40     *
41     * @return array<int, StructureNode> List of structure nodes.
42     */
43    public function findAllActive(): array;
44
45    /**
46     * Retrieves all active structure nodes assembled as hierarchical tree.
47     *
48     * @return array<int, StructureNode> Root level tree nodes with children.
49     */
50    public function getTree(): array;
51
52    /**
53     * Persists a structure node.
54     *
55     * @param StructureNode $node Node entity.
56     * @return int Persisted node ID.
57     */
58    public function save(StructureNode $node): int;
59
60    /**
61     * Deletes a structure node by ID.
62     *
63     * @param int $id Node ID.
64     * @return bool True on success.
65     */
66    public function delete(int $id): bool;
67
68    /**
69     * Counts direct child nodes of given structure node.
70     *
71     * @param int $structureId Structure ID.
72     * @return int Count of child nodes.
73     */
74    public function countChildNodes(int $structureId): int;
75
76    /**
77     * Counts how many records across all modules have this structure node as owner or co-owner.
78     *
79     * @param int $structureId Structure node ID.
80     * @return int Total records count.
81     */
82    public function countAssignedRecords(int $structureId): int;
83
84    /**
85     * Finds logo of the highest node in organizational hierarchy.
86     *
87     * Resolves root node (parent_id IS NULL) with configured logo, or falls back to the highest
88     * active node in hierarchy that has a non-empty logo specified.
89     *
90     * @return string|null Logo relative asset path or URL, or null if not found.
91     */
92    public function findHighestHierarchyLogo(): ?string;
93}