public function Batch::start in Simple XML sitemap 8.2
Starts the batch process depending on where it was requested from.
File
- src/
Batch.php, line 60
Class
- Batch
- Class Batch @package Drupal\simple_sitemap\Batch
Namespace
Drupal\simple_sitemapCode
public function start() {
switch ($this->batchSettings['from']) {
case 'form':
// Start batch process.
batch_set($this->batch);
return TRUE;
case 'drush':
// Start drush batch process.
batch_set($this->batch);
// See https://www.drupal.org/node/638712
$this->batch =& batch_get();
$this->batch['progressive'] = FALSE;
drush_log($this
->t(self::BATCH_INIT_MESSAGE), 'status');
drush_backend_batch_process();
return TRUE;
case 'backend':
// Start backend batch process.
batch_set($this->batch);
// See https://www.drupal.org/node/638712
$this->batch =& batch_get();
$this->batch['progressive'] = FALSE;
// todo: Does not take advantage of batch API and eventually runs out of memory on very large sites. Use queue API instead?
batch_process();
return TRUE;
case 'nobatch':
// Call each batch operation the way the Drupal batch API would do, but
// within one process (so in fact not using batch API here, just
// mimicking it to avoid code duplication).
$context = [];
foreach ($this->batch['operations'] as $i => $operation) {
$operation[1][] =& $context;
call_user_func_array($operation[0], $operation[1]);
}
$this
->finishGeneration(TRUE, !empty($context['results']) ? $context['results'] : [], []);
return TRUE;
}
return FALSE;
}