c9794634a0a0b384f767a3729eba430fcf1a5d03
[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  * @internal
12  */
13 class UserPermissionsRoleSpecificForm extends UserPermissionsForm {
14
15   /**
16    * The specific role for this form.
17    *
18    * @var \Drupal\user\RoleInterface
19    */
20   protected $userRole;
21
22   /**
23    * {@inheritdoc}
24    */
25   protected function getRoles() {
26     return [$this->userRole->id() => $this->userRole];
27   }
28
29   /**
30    * Builds the user permissions administration form for a specific role.
31    *
32    * @param array $form
33    *   An associative array containing the structure of the form.
34    * @param \Drupal\Core\Form\FormStateInterface $form_state
35    *   The current state of the form.
36    * @param \Drupal\user\RoleInterface|null $user_role
37    *   (optional) The user role used for this form. Defaults to NULL.
38    */
39   public function buildForm(array $form, FormStateInterface $form_state, RoleInterface $user_role = NULL) {
40     $this->userRole = $user_role;
41     return parent::buildForm($form, $form_state);
42   }
43
44 }