PluginProbe
The Innovative Form Builder – IvyForms / 1.5.1
The Innovative Form Builder – IvyForms v1.5.1
1.5.1 1.5 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 All 27 releases
← All changes | backend/src/Repository/BaseRepositoryInterface.php +134 -0 0.6.1 → 1.5.1 View file →
@@ -1,0 +1,134 @@
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 + * Bulk update a column for multiple entities by their IDs.
90 + *
91 + * @param string $column Column name to update
92 + * @param mixed $value Value to set
93 + * @param array<int> $ids Array of entity IDs
94 + * @return int Number of updated entities
95 + * @throws InvalidArgumentException If column is not allowed or IDs are empty
96 + */
97 + public function bulkUpdateColumn(string $column, $value, array $ids): int;
98 +
99 + /**
100 + * Search for entities based on parameters.
101 + *
102 + * @param array<string, mixed> $params
103 + * @return array<mixed>
104 + */
105 + public function search(array $params): array;
106 +
107 + /**
108 + * Select query for retrieving data.
109 + *
110 + * @return string
111 + */
112 + public function selectQuery(): string;
113 +
114 + /**
115 + * Begin a database transaction.
116 + *
117 + * @return bool
118 + */
119 + public function beginTransaction(): bool;
120 +
121 + /**
122 + * Commit a database transaction.
123 + *
124 + * @return bool
125 + */
126 + public function commit(): bool;
127 +
128 + /**
129 + * Rollback a database transaction.
130 + *
131 + * @return bool
132 + */
133 + public function rollback(): bool;
134 +}