private function RequireLoginSettingsForm::processPathInput in Require Login 8.2
Process user inputted path.
The path input. @var string $config_key The configuration key. @var \Drupal\Core\Form\FormStateInterface $form_state The form state.
1 call to RequireLoginSettingsForm::processPathInput()
- RequireLoginSettingsForm::validateForm in src/
Form/ RequireLoginSettingsForm.php - Form validation handler.
File
- src/
Form/ RequireLoginSettingsForm.php, line 144
Class
- RequireLoginSettingsForm
- Configure Require Login settings for this site.
Namespace
Drupal\require_login\FormCode
private function processPathInput(&$path, $config_key, FormStateInterface $form_state) {
$url_parts = parse_url(trim($path));
// Verify path is valid.
if (!UrlHelper::isValid($url_parts['path'])) {
$form_state
->setErrorByName($config_key, $this
->t('Invalid path: %s', [
'%s' => $path,
]));
return;
}
// Use parsed path in case user inputted schema and/or host.
$path = $url_parts['path'];
if (!empty($url_parts['query'])) {
$path .= '?' . $url_parts['query'];
}
// Prepend leading forward slash.
if (substr($path, 0, 1) !== '/') {
$path = '/' . $path;
}
}