You are here

function better_login_form_config_preprocess_better_login_form_config in Better Login Form Configuration 8.2

Implements hook_preprocess_HOOK().

1 string reference to 'better_login_form_config_preprocess_better_login_form_config'
better_login_form_config_theme in ./better_login_form_config.module
Implements hook_theme().

File

./better_login_form_config.module, line 86
Contains Drupal\better_login_form_config.

Code

function better_login_form_config_preprocess_better_login_form_config(&$variables) {
  $current_path = \Drupal::service('path.current')
    ->getPath();
  $patterns = "/user/login\n/user/password\n/user/register";
  $match = \Drupal::service('path.matcher')
    ->matchPath($current_path, $patterns);
  if ($match) {
    $variables['site_name'] = \Drupal::config('system.site')
      ->get('name');
    $variables['logo'] = theme_get_setting('logo.url');
    $myConfig = \Drupal::config('better_login_form_config.settings');
    $variables['forgot_password'] = $myConfig
      ->get('forgot_password');
    $variables['back_to_homes'] = $myConfig
      ->get('back_to_home');
    $variables['login_page_link'] = $myConfig
      ->get('login_page_link');

    // Register account link display if visitors have permission to
    // register their accounts.
    $register_url = Url::fromRoute('user.register');
    switch ($current_path) {
      case '/user/login':
        $variables['title'] = $myConfig
          ->get('form_title');
        if ($register_url
          ->access()) {
          $variables['create_accounts'] = $myConfig
            ->get('create_account');
        }
        break;
      case '/user/password':
        $title_forgot = $myConfig
          ->get('forgot_form_title');
        $variables['title'] = $title_forgot;
        if ($register_url
          ->access()) {
          $variables['create_accounts'] = $myConfig
            ->get('create_account');
        }
        break;
      case '/user/register':
        $regi_title = $myConfig
          ->get('register_form_title');
        $variables['title'] = $regi_title;
        break;
    }
    $variables['#cache']['contexts'][] = 'route';
    $variables['page']['#cache']['contexts'][] = 'route';
  }
}