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());
}