class PathMatcher implements PathMatcherInterface (View source)

Provides a path matcher.

Properties

protected bool $isCurrentFrontPage

Whether the current page is the front page.

protected string $frontPage

The default front page.

protected array $regexes

The cache of regular expressions.

protected ConfigFactoryInterface $configFactory

The config factory service.

protected RouteMatchInterface $routeMatch

The current route match.

Methods

__construct(ConfigFactoryInterface $config_factory, RouteMatchInterface $route_match)

Creates a new PathMatcher.

bool
matchPath(string $path, string $patterns)

Checks if a path matches any pattern in a set of patterns.

bool
isFrontPage()

Checks if the current page is the front page.

string
getFrontPagePath()

Gets the current front page path.

Details

__construct(ConfigFactoryInterface $config_factory, RouteMatchInterface $route_match)

Creates a new PathMatcher.

Parameters

ConfigFactoryInterface $config_factory

The config factory.

RouteMatchInterface $route_match

The current route match.

bool matchPath(string $path, string $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.

bool isFrontPage()

Checks if the current page is the front page.

Return Value

bool

TRUE if the current page is the front page.

protected string getFrontPagePath()

Gets the current front page path.

Return Value

string

The front page path.