PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Framework / Migrations / Contracts / BatchMigration.php

BatchMigration.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Framework/Migrations/Contracts/BatchMigration.php

61 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Framework\Migrations\Contracts;
4
5 /**
6 * Extend this class when you need database migration to run in batches.
7 *
8 * @since 4.0.0
9 */
10 abstract class BatchMigration extends BaseMigration
11 {
12 /**
13 * Get the number of items per batch
14 *
15 * @since 4.0.0
16 */
17 abstract public function getBatchSize(): int;
18
19 /**
20 *
21 * Get the total items count
22 *
23 * @since 4.0.0
24 */
25 abstract public function getItemsCount(): int;
26
27
28 /**
29 *
30 * Get the first and the last item ID for a batch
31 *
32 * @since 4.0.0
33 *
34 * @return array{0: int, 1: int} the first value is the first id and the second value is the last id of a batch
35 */
36 abstract public function getBatchItemsAfter($lastId): ?array;
37
38 /**
39 * Run batch
40 *
41 * @param $firstId - first item ID in batch
42 * @param $lastId - last item ID in batch
43 *
44 * @since 4.0.0
45 */
46 abstract public function runBatch($firstId, $lastId);
47
48 /**
49 * Last step of the migration process
50 *
51 * The purpose of this method is to check if we have new items that came during the migration.
52 *
53 * @since 4.0.0
54 *
55 * @param $lastProcessedId
56 *
57 * @return bool - true if there are new items, otherwise false
58 */
59 abstract public function hasMoreItemsToBatch($lastProcessedId): ?bool;
60 }
61