← All changes
|
backend/src/Repository/EntryField/EntryFieldRepositoryInterface.php
+91
-0
0.6.1
→
1.5
View file →
| @@ -1,0 +1,91 @@ | ||
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace IvyForms\Repository\EntryField; | |
| 4 | + | |
| 5 | +// phpcs:disable PSR1.Files.SideEffects | |
| 6 | +if (!defined('ABSPATH')) { | |
| 7 | + exit; // Exit if accessed directly | |
| 8 | +} | |
| 9 | + | |
| 10 | +use IvyForms\Entity\EntryField\EntryField; | |
| 11 | +use IvyForms\Repository\BaseRepositoryInterface; | |
| 12 | + | |
| 13 | +interface EntryFieldRepositoryInterface extends BaseRepositoryInterface | |
| 14 | +{ | |
| 15 | + /** | |
| 16 | + * Check if an entry field exists in the database. | |
| 17 | + * | |
| 18 | + * @param int $entryFieldId | |
| 19 | + * @return bool | |
| 20 | + */ | |
| 21 | + public function exists(int $entryFieldId): bool; | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * @param array<string, string> $array | |
| 25 | + * @return array<int, EntryField> | |
| 26 | + */ | |
| 27 | + public function findBy(array $array): array; | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * Get all entry field IDs for the given entry IDs. | |
| 31 | + * | |
| 32 | + * @param int[] $entryIds | |
| 33 | + * @return int[] | |
| 34 | + */ | |
| 35 | + public function findIdsByEntryIds(array $entryIds): array; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * Delete multiple entry fields by their IDs in a single query. | |
| 39 | + * | |
| 40 | + * @param int[] $formIds | |
| 41 | + * @return int Number of deleted rows | |
| 42 | + */ | |
| 43 | + public function deleteByFormIds(array $formIds): int; | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * Check if a value already exists in entry fields for a specific field. | |
| 47 | + * | |
| 48 | + * @param int $formId | |
| 49 | + * @param int $fieldId | |
| 50 | + * @param string $value | |
| 51 | + * @return bool | |
| 52 | + */ | |
| 53 | + public function checkDuplicateValue( | |
| 54 | + int $formId, | |
| 55 | + int $fieldId, | |
| 56 | + string $value, | |
| 57 | + ?int $excludeEntryId = null | |
| 58 | + ): bool; | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Check if a normalized value matches any stored value after applying a normalizer. | |
| 62 | + * | |
| 63 | + * @param int $formId | |
| 64 | + * @param int $fieldId | |
| 65 | + * @param string $normalizedValue | |
| 66 | + * @param callable(string): string $normalizeStoredValue | |
| 67 | + * @return bool | |
| 68 | + */ | |
| 69 | + public function checkDuplicateValueNormalized( | |
| 70 | + int $formId, | |
| 71 | + int $fieldId, | |
| 72 | + string $normalizedValue, | |
| 73 | + callable $normalizeStoredValue, | |
| 74 | + ?int $excludeEntryId = null | |
| 75 | + ): bool; | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * Batch-update fieldValue for existing entry_field rows of one entry. | |
| 79 | + * | |
| 80 | + * @param int $entryId | |
| 81 | + * @param list<array{id: int, fieldValue: string}> $updates | |
| 82 | + */ | |
| 83 | + public function batchUpdateValues(int $entryId, array $updates): void; | |
| 84 | + | |
| 85 | + /** | |
| 86 | + * Multi-row insert of entry_field rows. Sets generated IDs on the entities. | |
| 87 | + * | |
| 88 | + * @param list<EntryField> $entryFields | |
| 89 | + */ | |
| 90 | + public function batchInsert(array $entryFields): void; | |
| 91 | +} | |