You are here

protected function FormBuilder::buildFormAction in Secure Pages 8

Builds the $form['#action'].

Return value

string The URL to be used as the $form['#action'].

Overrides FormBuilder::buildFormAction

1 call to FormBuilder::buildFormAction()
FormBuilder::renderPlaceholderFormAction in src/FormBuilder.php
Renders a form action URL. It's a #lazy_builder callback.

File

src/FormBuilder.php, line 77
Contains \Drupal\securepages\FormBuilder.

Class

FormBuilder
FormBuilder decorator for the core formbuilder.

Namespace

Drupal\securepages

Code

protected function buildFormAction($form_id = '') {
  $url = parent::buildFormAction();
  $request = $this->requestStack
    ->getCurrentRequest();
  $config = \Drupal::config('securepages.settings');
  $is_https = $request
    ->isSecure();
  $path = \Drupal::service('path.current')
    ->getPath($request);
  $path_match = Securepages::matchPath($path);
  $role_match = Securepages::matchCurrentUser();
  $form_match = Securepages::matchFormId($form_id);
  if ($role_match || $path_match && !$is_https || !(!$path_match && $is_https && $config
    ->get('switch')) || $form_match) {
    $url = rtrim(Securepages::getUrl('<front>')
      ->toString(), '/') . $url;
  }
  return $url;
}