comparison core/modules/user/src/Form/UserMultipleCancelConfirm.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 1fec387a4317
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
3 namespace Drupal\user\Form; 3 namespace Drupal\user\Form;
4 4
5 use Drupal\Core\Entity\EntityManagerInterface; 5 use Drupal\Core\Entity\EntityManagerInterface;
6 use Drupal\Core\Form\ConfirmFormBase; 6 use Drupal\Core\Form\ConfirmFormBase;
7 use Drupal\Core\Form\FormStateInterface; 7 use Drupal\Core\Form\FormStateInterface;
8 use Drupal\Core\Messenger\MessengerInterface;
8 use Drupal\Core\Url; 9 use Drupal\Core\Url;
9 use Drupal\Core\TempStore\PrivateTempStoreFactory; 10 use Drupal\Core\TempStore\PrivateTempStoreFactory;
10 use Drupal\user\UserStorageInterface; 11 use Drupal\user\UserStorageInterface;
11 use Symfony\Component\DependencyInjection\ContainerInterface; 12 use Symfony\Component\DependencyInjection\ContainerInterface;
12 13
130 131
131 // Output a notice that user 1 cannot be canceled. 132 // Output a notice that user 1 cannot be canceled.
132 if (isset($root)) { 133 if (isset($root)) {
133 $redirect = (count($accounts) == 1); 134 $redirect = (count($accounts) == 1);
134 $message = $this->t('The user account %name cannot be canceled.', ['%name' => $root->label()]); 135 $message = $this->t('The user account %name cannot be canceled.', ['%name' => $root->label()]);
135 drupal_set_message($message, $redirect ? 'error' : 'warning'); 136 $this->messenger()->addMessage($message, $redirect ? MessengerInterface::TYPE_ERROR : MessengerInterface::TYPE_WARNING);
136 // If only user 1 was selected, redirect to the overview. 137 // If only user 1 was selected, redirect to the overview.
137 if ($redirect) { 138 if ($redirect) {
138 return $this->redirect('entity.user.collection'); 139 return $this->redirect('entity.user.collection');
139 } 140 }
140 } 141 }