protected function StaticGeneratorForm::setBatch in Tome 8
Sets a new batch.
Parameters
array $paths: An array of paths to invoke.
string $base_url: The base URL.
2 calls to StaticGeneratorForm::setBatch()
- StaticGeneratorForm::batchInvokePaths in modules/
tome_static/ src/ Form/ StaticGeneratorForm.php - Exports all remaining paths at the end of a previous batch.
- StaticGeneratorForm::submitForm in modules/
tome_static/ src/ Form/ StaticGeneratorForm.php - Form submission handler.
File
- modules/
tome_static/ src/ Form/ StaticGeneratorForm.php, line 246
Class
- StaticGeneratorForm
- Contains a form for initializing a static build.
Namespace
Drupal\tome_static\FormCode
protected function setBatch(array $paths, $base_url) {
$batch_builder = (new BatchBuilder())
->setTitle($this
->t('Generating static HTML...'))
->setFinishCallback([
$this,
'finishCallback',
]);
$paths = $this->static
->exportPaths($paths);
foreach ($paths as $path) {
$batch_builder
->addOperation([
$this,
'exportPath',
], [
$path,
$base_url,
]);
}
$batch_builder
->addOperation([
$this,
'batchInvokePaths',
], [
$base_url,
]);
batch_set($batch_builder
->toArray());
}