public PathMatcher::matchPath($path, $patterns)
Checks if a path matches any pattern in a set of patterns.
Parameters
string $path: The path to match.
string $patterns: A set of patterns separated by a newline.
Return value
bool TRUE if the path matches a pattern, FALSE otherwise.
Overrides PathMatcherInterface::matchPath
File
- core/lib/Drupal/Core/Path/PathMatcher.php, line 65
Class
- PathMatcher
- Provides a path matcher.
Namespace
Drupal\Core\Path
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | public function matchPath( $path , $patterns ) { if (!isset( $this ->regexes[ $patterns ])) { // Convert path settings to a regular expression. $to_replace = array ( // Replace newlines with a logical 'or'. '/(\r\n?|\n)/' , // Quote asterisks. '/\\\\\*/' , // Quote <front> keyword. '/(^|\|)\\\\<front\\\\>($|\|)/' , ); $replacements = array ( '|' , '.*' , '\1' . preg_quote( $this ->getFrontPagePath(), '/' ) . '\2' , ); $patterns_quoted = preg_quote( $patterns , '/' ); $this ->regexes[ $patterns ] = '/^(' . preg_replace( $to_replace , $replacements , $patterns_quoted ) . ')$/' ; } return (bool) preg_match( $this ->regexes[ $patterns ], $path ); } |
Please login to continue.