805df2b9e432721a7113c58678ac281a9e1294b7
[yaffs-website] / web / core / modules / user / src / Plugin / views / field / UserBulkForm.php
1 <?php
2
3 namespace Drupal\user\Plugin\views\field;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\user\UserInterface;
7 use Drupal\views\Plugin\views\field\BulkForm;
8
9 /**
10  * Defines a user operations bulk form element.
11  *
12  * @ViewsField("user_bulk_form")
13  */
14 class UserBulkForm extends BulkForm {
15
16   /**
17    * {@inheritdoc}
18    *
19    * Provide a more useful title to improve the accessibility.
20    */
21   public function viewsForm(&$form, FormStateInterface $form_state) {
22     parent::viewsForm($form, $form_state);
23
24     if (!empty($this->view->result)) {
25       foreach ($this->view->result as $row_index => $result) {
26         $account = $result->_entity;
27         if ($account instanceof UserInterface) {
28           $form[$this->options['id']][$row_index]['#title'] = $this->t('Update the user %name', ['%name' => $account->label()]);
29         }
30       }
31     }
32   }
33
34   /**
35    * {@inheritdoc}
36    */
37   protected function emptySelectedMessage() {
38     return $this->t('No users selected.');
39   }
40
41 }