b8caf7bbf47ab0e7f73479f3ac689010567df58c
[yaffs-website] / web / core / modules / user / src / Form / UserPermissionsRoleSpecificForm.php
1 <?php
2
3 namespace Drupal\user\Form;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\user\RoleInterface;
7
8 /**
9  * Provides the user permissions administration form for a specific role.
10  */
11 class UserPermissionsRoleSpecificForm extends UserPermissionsForm {
12
13   /**
14    * The specific role for this form.
15    *
16    * @var \Drupal\user\RoleInterface
17    */
18   protected $userRole;
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function getRoles() {
24     return [$this->userRole->id() => $this->userRole];
25   }
26
27   /**
28    * Builds the user permissions administration form for a specific role.
29    *
30    * @param array $form
31    *   An associative array containing the structure of the form.
32    * @param \Drupal\Core\Form\FormStateInterface $form_state
33    *   The current state of the form.
34    * @param \Drupal\user\RoleInterface|null $user_role
35    *   (optional) The user role used for this form. Defaults to NULL.
36    */
37   public function buildForm(array $form, FormStateInterface $form_state, RoleInterface $user_role = NULL) {
38     $this->userRole = $user_role;
39     return parent::buildForm($form, $form_state);
40   }
41
42 }