function amp_node_form_submit in Accelerated Mobile Pages (AMP) 8.2
Same name and namespace in other branches
- 8.3 amp.module \amp_node_form_submit()
- 8 amp.module \amp_node_form_submit()
- 7 amp.module \amp_node_form_submit()
Submit handler for viewing the AMP page.
1 string reference to 'amp_node_form_submit'
- amp_form_node_form_alter in ./
amp.module - Implements hook_form_BASE_FORM_ID_alter().
File
- ./
amp.module, line 341
Code
function amp_node_form_submit(&$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_url = \Drupal::service('amp.query_parameters')
->add($url);
$response = new RedirectResponse($amp_url);
$response
->send();
}
}