Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / user / src / RoleListBuilder.php
1 <?php
2
3 namespace Drupal\user;
4
5 use Drupal\Core\Config\Entity\DraggableListBuilder;
6 use Drupal\Core\Entity\EntityInterface;
7 use Drupal\Core\Form\FormStateInterface;
8
9 /**
10  * Defines a class to build a listing of user role entities.
11  *
12  * @see \Drupal\user\Entity\Role
13  */
14 class RoleListBuilder extends DraggableListBuilder {
15
16   /**
17    * {@inheritdoc}
18    */
19   public function getFormId() {
20     return 'user_admin_roles_form';
21   }
22
23   /**
24    * {@inheritdoc}
25    */
26   public function buildHeader() {
27     $header['label'] = t('Name');
28     return $header + parent::buildHeader();
29   }
30
31   /**
32    * {@inheritdoc}
33    */
34   public function buildRow(EntityInterface $entity) {
35     $row['label'] = $entity->label();
36     return $row + parent::buildRow($entity);
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public function getDefaultOperations(EntityInterface $entity) {
43     $operations = parent::getDefaultOperations($entity);
44
45     if ($entity->hasLinkTemplate('edit-permissions-form')) {
46       $operations['permissions'] = [
47         'title' => t('Edit permissions'),
48         'weight' => 20,
49         'url' => $entity->urlInfo('edit-permissions-form'),
50       ];
51     }
52     return $operations;
53   }
54
55   /**
56    * {@inheritdoc}
57    */
58   public function submitForm(array &$form, FormStateInterface $form_state) {
59     parent::submitForm($form, $form_state);
60
61     drupal_set_message(t('The role settings have been updated.'));
62   }
63
64 }