function AliasPathMatcher::isAliasFrontPage

Checks if the current page is the front page by comparing aliases.

1 call to AliasPathMatcher::isAliasFrontPage()
AliasPathMatcher::isFrontPage in core/modules/path_alias/src/AliasPathMatcher.php
Checks if the current page is the front page.

File

core/modules/path_alias/src/AliasPathMatcher.php, line 48

Class

AliasPathMatcher
Extends the default path matcher to check aliases.

Namespace

Drupal\path_alias

Code

protected function isAliasFrontPage() : bool {
  // Ensure that the code can also be executed when there is no active
  // route match, like on exception responses.
  if (!$this->routeMatch
    ->getRouteName()) {
    return FALSE;
  }
  $url = Url::fromRouteMatch($this->routeMatch);
  $path = '/' . $url->getInternalPath();
  $frontPagePath = $this->configFactory
    ->get('system.site')
    ->get('page.front');
  return $this->aliasManager
    ->getAliasByPath($path) === $frontPagePath;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.