You are here

function simplesamlphp_auth_form_user_login_form_alter in simpleSAMLphp Authentication 8.3

Implements hook_form_FORM_ID_alter().

File

./simplesamlphp_auth.module, line 169
SimpleSAMLphp authentication module for Drupal.

Code

function simplesamlphp_auth_form_user_login_form_alter(&$form, FormStateInterface $form_state, $form_id) {

  // Return without executing if the functionality is not enabled.
  $config = \Drupal::config('simplesamlphp_auth.settings');
  \Drupal::service('renderer')
    ->addCacheableDependency($form, $config);
  if (!$config
    ->get('activate') || !$config
    ->get('login_link_show')) {
    return;
  }
  $label = $config
    ->get('login_link_display_name');
  $form['simplesamlphp_auth_login_link'] = [
    '#title' => $label,
    '#type' => 'link',
    '#url' => Url::fromRoute('simplesamlphp_auth.saml_login'),
    '#attributes' => [
      'title' => $label,
      'class' => [
        'simplesamlphp-auth-login-link',
      ],
    ],
  ];
}