You are here

function amp_node_form_submit_with_warn in Accelerated Mobile Pages (AMP) 8

Same name and namespace in other branches
  1. 8.2 amp.module \amp_node_form_submit_with_warn()

Submit handler for viewing the AMP page. Redirects to a url to displays all warnings generated by AMP Library from AMP Text formatters used

1 string reference to 'amp_node_form_submit_with_warn'
amp_form_node_form_alter in ./amp.module
Implements hook_form_BASE_FORM_ID_alter().

File

./amp.module, line 378

Code

function amp_node_form_submit_with_warn(&$form, FormStateInterface $form_state) {
  $path = $form_state
    ->getValue('path');

  // Redirect to the alias if it exists, otherwise use the node URL.
  $url = !empty($path[0]['alias']) ? $path[0]['alias'] : $path[0]['source'];
  if (isset($url)) {
    $amp_warnfix_url = \Drupal::service('amp.query_parameters')
      ->add($url, $warnfix = TRUE);
    $response = new RedirectResponse($amp_warnfix_url);
    $response
      ->send();
  }
}