You are here

public function AssignMultiple::submitForm in Translation Management Tool 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

translators/tmgmt_local/src/Form/AssignMultiple.php, line 92

Class

AssignMultiple
Provides a node deletion confirmation form.

Namespace

Drupal\tmgmt_local\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  /** @var User $assignee */
  $assignee = User::load($form_state
    ->getValue('tuid'));
  $how_many = 0;
  foreach ($form_state
    ->get('tasks') as $task_id) {
    $task = LocalTask::load($task_id);
    if ($task) {
      $task
        ->assign($assignee);
      $task
        ->save();
      ++$how_many;
    }
  }
  $this
    ->messenger()
    ->addStatus(t('Assigned @how_many to user @assignee_name.', array(
    '@how_many' => $how_many,
    '@assignee_name' => $assignee
      ->getAccountName(),
  )));
  $view = Views::getView('tmgmt_local_task_overview');
  $view
    ->initDisplay();
  $form_state
    ->setRedirect($view
    ->getUrl()
    ->getRouteName());
}