Elgg  Version master
Batch.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Upgrade;
4 
10 abstract class Batch {
11 
15  const UNKNOWN_COUNT = -1;
16 
22  public function __construct(protected ?\ElggUpgrade $upgrade = null) {
23  }
24 
39  abstract public function getVersion(): int;
40 
48  abstract public function shouldBeSkipped(): bool;
49 
63  abstract public function needsIncrementOffset(): bool;
64 
73  abstract public function countItems(): int;
74 
86  abstract public function run(Result $result, $offset): Result;
87 
94  final public function getUpgrade(): ?\ElggUpgrade {
95  return $this->upgrade;
96  }
97 }
getVersion()
Version of the upgrade.
if(empty($count)) $offset
Definition: pagination.php:26
countItems()
The total number of items to process during the upgrade.
shouldBeSkipped()
Should this upgrade be skipped?
getUpgrade()
Returns the related upgrade entity.
Definition: Batch.php:94
if(empty($guid)) $upgrade
Definition: upgrade.php:11
const UNKNOWN_COUNT
countItems() should return this if it doesn&#39;t know how many items remain.
Definition: Batch.php:15
Represents an upgrade that runs outside of the upgrade.php script.
Definition: ElggUpgrade.php:26
Long running upgrades should implement this interface.
Definition: Batch.php:10
Result of a single BatchUpgrade run.
Definition: Result.php:10
run(Result $result, $offset)
Runs upgrade on a single batch of items.
__construct(protected?\ElggUpgrade $upgrade=null)
Constructs a upgrade batch.
Definition: Batch.php:22
needsIncrementOffset()
Should the run() method receive an offset representing all processed items?