You are here

public function SecureLoginManager::secureUrl in Secure Login 8

Rewrites a URL to use the secure base URL.

2 calls to SecureLoginManager::secureUrl()
SecureLoginManager::renderPlaceholderFormAction in src/SecureLoginManager.php
Lazy builder callback; renders a form action URL including destination.
SecureLoginManager::secureForm in src/SecureLoginManager.php
Rewrites the form action to use the secure base URL.

File

src/SecureLoginManager.php, line 113

Class

SecureLoginManager
Defines the secure login service.

Namespace

Drupal\securelogin

Code

public function secureUrl($url) {
  global $base_path, $base_secure_url;

  // Set the form action to use secure base URL in place of base path.
  if (strpos($url, $base_path) === 0) {
    $base_url = $this->config
      ->get('base_url') ?: $base_secure_url;
    return substr_replace($url, $base_url, 0, strlen($base_path) - 1);
  }

  // Or if a different domain is being used, forcibly rewrite to HTTPS.
  return str_replace('http://', 'https://', $url);
}