You are here

private function EntityConfigSettingsForm::buildUserRoleWarningForm in Acquia Content Hub 8

Build user role form warning.

Return value

array User role warning form.

1 call to EntityConfigSettingsForm::buildUserRoleWarningForm()
EntityConfigSettingsForm::buildForm in src/Form/EntityConfigSettingsForm.php
Form constructor.

File

src/Form/EntityConfigSettingsForm.php, line 298

Class

EntityConfigSettingsForm
Defines the form to configure the entity types and bundles to be exported.

Namespace

Drupal\acquia_contenthub\Form

Code

private function buildUserRoleWarningForm() {
  $admin_roles = $this
    ->getRestrictedRoles();
  $form = [];
  if (!empty($admin_roles)) {
    $states = [];
    foreach ($admin_roles as $role_id => $role_label) {
      $states[] = [
        ':input[name="user_role"]' => [
          'value' => $role_id,
        ],
      ];
    }
    $form = [
      'container' => [
        '#type' => 'container',
        '#states' => [
          'visible' => $states,
        ],
        'warning' => [
          '#type' => 'inline_template',
          '#template' => '<div class="permission"><span class="title">{{ title }}</span></div>',
          '#context' => [
            'title' => $this
              ->t('Warning: This role has security implications.'),
          ],
        ],
        '#attributes' => [
          'id' => 'user-warning-role',
        ],
      ],
    ];
  }
  return $form;
}