PluginProbe
The Innovative Form Builder – IvyForms / 0.8
The Innovative Form Builder – IvyForms v0.8
1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 1.2 1.3
ivyforms / backend / src / Repository / BaseRepositoryInterface.php

BaseRepositoryInterface.php in The Innovative Form Builder – IvyForms 0.8, at backend/src/Repository/BaseRepositoryInterface.php

124 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Repository;
4
5 // phpcs:disable PSR1.Files.SideEffects
6 if (!defined('ABSPATH')) {
7 exit; // Exit if accessed directly
8 }
9
10 use IvyForms\Common\Exceptions\InvalidArgumentException;
11
12 /**
13 * Interface BaseRepositoryInterface
14 *
15 * @package IvyForms\Repository
16 */
17 interface BaseRepositoryInterface
18 {
19 /**
20 * Get an entity by ID.
21 *
22 * @param int $id
23 *
24 * @return object|null
25 */
26 public function getById(int $id): ?object;
27
28 /**
29 * Get all entities.
30 *
31 * @return mixed[]|null
32 */
33 public function getAll(): ?array;
34
35 /**
36 * Add an entity.
37 *
38 * @param object $entity
39 * @return int
40 */
41 public function add(object $entity): int;
42
43 /**
44 * Update an entity by ID.
45 *
46 * @param int $id
47 * @param object $entity
48 * @return bool
49 */
50 public function update(int $id, object $entity): bool;
51
52 /**
53 * Delete an entity by ID.
54 *
55 * @param int $id
56 * @return int
57 */
58 public function delete(int $id): int;
59
60 /**
61 * Delete multiple entities by their IDs in bulk.
62 *
63 * @param array<int> $ids
64 * @return int Number of deleted entities
65 */
66 public function deleteMany(array $ids): int;
67
68 /**
69 * Delete multiple entities by foreign key values (e.g., form IDs).
70 *
71 * @param array<int> $foreignIds Array of foreign key values (e.g., form IDs)
72 * @param string $foreignColumn Foreign key column name (default: 'formId')
73 * @return int Number of deleted entities
74 * @throws InvalidArgumentException If no foreign IDs are provided
75 */
76 public function deleteManyByForeignKeyValues(array $foreignIds, string $foreignColumn = 'formId'): int;
77
78 /**
79 * Delete entities by a single foreign key value (e.g., form ID).
80 *
81 * @param int $foreignId Foreign key value (e.g., form ID)
82 * @param string $foreignColumn Foreign key column name (default: 'formId')
83 * @return int Number of deleted entities
84 * @throws InvalidArgumentException If invalid foreign column is provided
85 */
86 public function deleteOneByForeignKeyValue(int $foreignId, string $foreignColumn = 'formId'): int;
87
88 /**
89 * Search for entities based on parameters.
90 *
91 * @param array<string, mixed> $params
92 * @return array<mixed>
93 */
94 public function search(array $params): array;
95
96 /**
97 * Select query for retrieving data.
98 *
99 * @return string
100 */
101 public function selectQuery(): string;
102
103 /**
104 * Begin a database transaction.
105 *
106 * @return bool
107 */
108 public function beginTransaction(): bool;
109
110 /**
111 * Commit a database transaction.
112 *
113 * @return bool
114 */
115 public function commit(): bool;
116
117 /**
118 * Rollback a database transaction.
119 *
120 * @return bool
121 */
122 public function rollback(): bool;
123 }
124