protected function PathPluginBase::validatePath in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/display/PathPluginBase.php \Drupal\views\Plugin\views\display\PathPluginBase::validatePath()
- 9 core/modules/views/src/Plugin/views/display/PathPluginBase.php \Drupal\views\Plugin\views\display\PathPluginBase::validatePath()
Validates the path of the display.
Parameters
string $path: The path to validate.
Return value
array A list of error strings.
2 calls to PathPluginBase::validatePath()
- PathPluginBase::validate in core/
modules/ views/ src/ Plugin/ views/ display/ PathPluginBase.php - Make sure the display and all associated handlers are valid.
- PathPluginBase::validateOptionsForm in core/
modules/ views/ src/ Plugin/ views/ display/ PathPluginBase.php - Validates the options form.
File
- core/
modules/ views/ src/ Plugin/ views/ display/ PathPluginBase.php, line 493
Class
- PathPluginBase
- The base display plugin for path/callbacks. This is used for pages and feeds.
Namespace
Drupal\views\Plugin\views\displayCode
protected function validatePath($path) {
$errors = [];
if (strpos($path, '%') === 0) {
$errors[] = $this
->t('"%" may not be used for the first segment of a path.');
}
$parsed_url = UrlHelper::parse($path);
if (empty($parsed_url['path'])) {
$errors[] = $this
->t('Path is empty.');
}
if (!empty($parsed_url['query'])) {
$errors[] = $this
->t('No query allowed.');
}
if (!parse_url('internal:/' . $path)) {
$errors[] = $this
->t('Invalid path. Valid characters are alphanumerics as well as "-", ".", "_" and "~".');
}
$path_sections = explode('/', $path);
// Symfony routing does not allow to use numeric placeholders.
// @see \Symfony\Component\Routing\RouteCompiler
$numeric_placeholders = array_filter($path_sections, function ($section) {
return preg_match('/^%(.*)/', $section, $matches) && is_numeric($matches[1]);
});
if (!empty($numeric_placeholders)) {
$errors[] = $this
->t("Numeric placeholders may not be used. Please use plain placeholders (%).");
}
return $errors;
}