protected function LingotekManagementFormBase::createBatch in Lingotek Translation 4.0.x
Same name and namespace in other branches
- 8.2 src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::createBatch()
- 3.0.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::createBatch()
- 3.1.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::createBatch()
- 3.2.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::createBatch()
- 3.3.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::createBatch()
- 3.4.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::createBatch()
- 3.5.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::createBatch()
- 3.6.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::createBatch()
- 3.7.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::createBatch()
- 3.8.x src/Form/LingotekManagementFormBase.php \Drupal\lingotek\Form\LingotekManagementFormBase::createBatch()
Performs an operation to several values in a batch.
Parameters
string $operation: The method in this object we need to call.
array $values: Array of ids to process.
string $title: The title for the batch progress.
string $language: (Optional) The language code for the request. NULL if is not applicable.
string $job_id: (Optional) The job ID to be used. NULL if is not applicable.
11 calls to LingotekManagementFormBase::createBatch()
- LingotekManagementFormBase::createCancelBatch in src/
Form/ LingotekManagementFormBase.php - Create and set a cancellation batch.
- LingotekManagementFormBase::createChangeProfileBatch in src/
Form/ LingotekManagementFormBase.php - Create and set a profile change batch.
- LingotekManagementFormBase::createDownloadBatch in src/
Form/ LingotekManagementFormBase.php - Create and set a request target and download batch for all languages.
- LingotekManagementFormBase::createLanguageDownloadBatch in src/
Form/ LingotekManagementFormBase.php - Create and set a request target and download batch for a given language.
- LingotekManagementFormBase::createLanguageRequestTranslationBatch in src/
Form/ LingotekManagementFormBase.php - Create and set a request translations batch for all languages.
File
- src/
Form/ LingotekManagementFormBase.php, line 691
Class
- LingotekManagementFormBase
- Form for bulk management of content.
Namespace
Drupal\lingotek\FormCode
protected function createBatch($operation, $values, $title, $language = NULL, $job_id = NULL) {
$operations = [];
$entities = $this
->getSelectedEntities($values);
foreach ($entities as $entity) {
$split_download_all = $this->lingotekConfiguration
->getPreference('split_download_all');
if ($operation == 'downloadTranslations' && $split_download_all) {
$languages = $this->languageManager
->getLanguages();
foreach ($languages as $langcode => $language) {
if ($langcode !== $entity
->language()
->getId()) {
$operations[] = [
[
$this,
'downloadTranslation',
],
[
$entity,
$langcode,
$job_id,
],
];
}
}
}
else {
$operations[] = [
[
$this,
$operation,
],
[
$entity,
$language,
$job_id,
],
];
}
}
$batch = [
'title' => $title,
'operations' => $operations,
'finished' => [
$this,
'batchFinished',
],
'progressive' => TRUE,
'batch_redirect' => $this
->getRequest()
->getUri(),
];
batch_set($batch);
}