You are here

public function LingotekManagementForm::submitForm in Lingotek Translation 8

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/LingotekManagementForm.php, line 409
Contains \Drupal\Lingotek\Form\LingotekManagementForm.

Class

LingotekManagementForm
Form for bulk management of content.

Namespace

Drupal\lingotek\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $operation = $form_state
    ->getValue('operation');
  $values = array_keys(array_filter($form_state
    ->getValue([
    'table',
  ], function ($key, $value) {
    return $value;
  })));
  $processed = FALSE;
  switch ($operation) {
    case 'debug.export':
      $this
        ->createDebugExportBatch($values);
      $processed = TRUE;
      break;
    case 'upload':
      $this
        ->createUploadBatch($values);
      $processed = TRUE;
      break;
    case 'check_upload':
      $this
        ->createUploadCheckStatusBatch($values);
      $processed = TRUE;
      break;
    case 'request_translations':
      $this
        ->createRequestTranslationsBatch($values);
      $processed = TRUE;
      break;
    case 'check_translations':
      $this
        ->createTranslationCheckStatusBatch($values);
      $processed = TRUE;
      break;
    case 'download':
      $this
        ->createDownloadBatch($values);
      $processed = TRUE;
      break;
    case 'disassociate':
      $this
        ->createDisassociateBatch($values);
      $processed = TRUE;
      break;
    case 'delete_nodes':
      $this
        ->redirectToDeleteMultipleNodesForm($values, $form_state);
      $processed = TRUE;
      break;
  }
  if (!$processed) {
    if (0 === strpos($operation, 'request_translation:')) {
      list($operation, $language) = explode(':', $operation);
      $this
        ->createLanguageRequestTranslationBatch($values, $language);
      $processed = TRUE;
    }
    if (0 === strpos($operation, 'check_translation:')) {
      list($operation, $language) = explode(':', $operation);
      $this
        ->createLanguageTranslationCheckStatusBatch($values, $language);
      $processed = TRUE;
    }
    if (0 === strpos($operation, 'download:')) {
      list($operation, $language) = explode(':', $operation);
      $this
        ->createLanguageDownloadBatch($values, $language);
      $processed = TRUE;
    }
    if (0 === strpos($operation, 'change_profile:')) {
      list($operation, $profile_id) = explode(':', $operation);
      $this
        ->createChangeProfileBatch($values, $profile_id);
      $processed = TRUE;
    }
  }
}