You are here

public static function Securepages::getUrl in Secure Pages 8

Get base URL from configuration or compute it if not set.

Parameters

string $route_name: The route name. Defaults to the front page.

array $route_parameters: (optional) An associative array of route parameter names and values.

array $options: (optional) An associative array of additional URL options, see \Drupal\Core\Url::fromRoute().

bool $secure: (optional) Whether to generate the secure URL or the insecure URL. Defaults to secure.

Return value

\Drupal\Core\Url The secure or non-secure base URL.

3 calls to Securepages::getUrl()
SecurepagesTest::drupalLoginHttps in src/Tests/SecurepagesTest.php
Log in a user with the internal browser using HTTPS.
SecurepagesTest::drupalLogoutHttps in src/Tests/SecurepagesTest.php
Logs a user out of the internal browser and confirms.
SecurepagesTest::_testSettingsForm in src/Tests/SecurepagesTest.php
Test submitting the settings form.

File

src/Securepages.php, line 172
Contains \Drupal\securepages\Securepages.

Class

Securepages
Utility class for global functionality.

Namespace

Drupal\securepages

Code

public static function getUrl($route_name = '<front>', $route_parameters = [], $options = [], $secure = TRUE) {
  $options += [
    'https' => $secure,
    'absolute' => TRUE,
  ];
  if ($config_url = \Drupal::config('securepages.settings')
    ->get('basepath' . ($secure ? '_ssl' : ''))) {
    $options['base_url'] = $config_url;
  }
  return Url::fromRoute($route_name, $route_parameters, $options);
}