class FeedsBatchBatch in Feeds 8.3
A batch task for the batch API.
Hierarchy
- class \Drupal\feeds\FeedsBatchBase implements FeedsBatchInterface
- class \Drupal\feeds\FeedsBatchBatch uses StringTranslationTrait
Expanded class hierarchy of FeedsBatchBatch
File
- src/
FeedsBatchBatch.php, line 10
Namespace
Drupal\feedsView source
class FeedsBatchBatch extends FeedsBatchBase {
use StringTranslationTrait;
/**
* Adds a new batch.
*
* @param array $batch_definition
* An associative array defining the batch.
*/
protected function batchSet(array $batch_definition) {
return batch_set($batch_definition);
}
/**
* {@inheritdoc}
*/
public function run() {
$batch = [
'title' => '',
'operations' => [],
];
foreach ($this->operations as $operation) {
$batch['operations'][] = [
[
$this->executable,
'processItem',
],
[
$this->feed,
$operation['stage'],
$operation['params'],
],
];
}
switch ($this->stage) {
case FeedsExecutableInterface::FETCH:
$batch['title'] = $this
->t('Fetching: %title', [
'%title' => $this->feed
->label(),
]);
$batch['error_message'] = $this
->t('An error occurred while fetching %title.', [
'%title' => $this->feed
->label(),
]);
break;
case FeedsExecutableInterface::PARSE:
$batch['title'] = $this
->t('Parsing: %title', [
'%title' => $this->feed
->label(),
]);
$batch['error_message'] = $this
->t('An error occurred while parsing %title.', [
'%title' => $this->feed
->label(),
]);
break;
case FeedsExecutableInterface::PROCESS:
$batch['title'] = $this
->t('Processing: %title', [
'%title' => $this->feed
->label(),
]);
$batch['error_message'] = $this
->t('An error occurred while processing %title.', [
'%title' => $this->feed
->label(),
]);
break;
case FeedsExecutableInterface::CLEAN:
$batch['title'] = $this
->t('Cleaning: %title', [
'%title' => $this->feed
->label(),
]);
$batch['error_message'] = $this
->t('An error occurred while cleaning %title.', [
'%title' => $this->feed
->label(),
]);
break;
}
$batch += [
'init_message' => $batch['title'],
'progress_message' => $batch['title'],
];
$this
->batchSet($batch);
return $this;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeedsBatchBase:: |
protected | property | The Feeds executable. | |
FeedsBatchBase:: |
protected | property | The feed to run a batch for. | |
FeedsBatchBase:: |
protected | property | A list of operations to run. | |
FeedsBatchBase:: |
protected | property | The stage of the batch to run. | |
FeedsBatchBase:: |
public | function |
Adds an operation. Overrides FeedsBatchInterface:: |
|
FeedsBatchBase:: |
public | function | Constructs a new FeedsBatchBase object. | 1 |
FeedsBatchBatch:: |
protected | function | Adds a new batch. | |
FeedsBatchBatch:: |
public | function |
Runs the batch. Overrides FeedsBatchInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |