| @@ -6,8 +6,10 @@ | ||
| 6 | 6 | if (!defined('ABSPATH')) { |
| 7 | 7 | exit; // Exit if accessed directly |
| 8 | 8 | } |
| 9 | 9 | |
| 10 | +use IvyForms\Common\Exceptions\InvalidArgumentException; | |
| 11 | + | |
| 10 | 12 | /** |
| 11 | 13 | * Interface BaseRepositoryInterface |
| 12 | 14 | * |
| 13 | 15 | * @package IvyForms\Repository |
| @@ -55,15 +57,45 @@ | ||
| 55 | 57 | */ |
| 56 | 58 | public function delete(int $id): int; |
| 57 | 59 | |
| 58 | 60 | /** |
| 59 | - * Delete many entities. | |
| 61 | + * Delete multiple entities by their IDs in bulk. | |
| 60 | 62 | * |
| 61 | 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). | |
| 62 | 70 | * |
| 63 | - * @return int | |
| 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 | |
| 64 | 75 | */ |
| 65 | - public function deleteMany(array $ids): int; | |
| 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; | |
| 66 | 98 | |
| 67 | 99 | /** |
| 68 | 100 | * Search for entities based on parameters. |
| 69 | 101 | * |