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 
20  protected $upgrade;
21 
27  public function __construct(\ElggUpgrade $upgrade = null) {
28  $this->upgrade = $upgrade;
29  }
30 
45  abstract public function getVersion(): int;
46 
54  abstract public function shouldBeSkipped(): bool;
55 
69  abstract public function needsIncrementOffset(): bool;
70 
79  abstract public function countItems(): int;
80 
92  abstract public function run(Result $result, $offset): Result;
93 
100  final public function getUpgrade(): ?\ElggUpgrade {
101  return $this->upgrade;
102  }
103 }
getVersion()
Version of the upgrade.
if(empty($count)) $offset
Definition: pagination.php:26
__construct(\ElggUpgrade $upgrade=null)
Constructs a upgrade batch.
Definition: Batch.php:27
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:100
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.
needsIncrementOffset()
Should the run() method receive an offset representing all processed items?