Skip to content
Snippets Groups Projects

Issue #1503146: drupal_is_front_page() does not detect Front Page in some cases

Open Issue #1503146: drupal_is_front_page() does not detect Front Page in some cases
1 unresolved thread
1 unresolved thread
Files
4
@@ -91,17 +91,27 @@ public function matchPath($path, $patterns) {
@@ -91,17 +91,27 @@ public function matchPath($path, $patterns) {
public function isFrontPage() {
public function isFrontPage() {
// Cache the result as this is called often.
// Cache the result as this is called often.
if (!isset($this->isCurrentFrontPage)) {
if (!isset($this->isCurrentFrontPage)) {
$this->isCurrentFrontPage = FALSE;
$this->isCurrentFrontPage = $this->checkFrontPage();
// Ensure that the code can also be executed when there is no active
// route match, like on exception responses.
if ($this->routeMatch->getRouteName()) {
$url = Url::fromRouteMatch($this->routeMatch);
$this->isCurrentFrontPage = ($url->getRouteName() && '/' . $url->getInternalPath() === $this->getFrontPagePath());
}
}
}
return $this->isCurrentFrontPage;
return $this->isCurrentFrontPage;
}
}
 
/**
 
* Checks if the current page is the front page, without caching the result.
 
*
 
* @return bool
 
* TRUE if the current page is the front page.
 
*/
 
protected function checkFrontPage() {
 
// Ensure that the code can also be executed when there is no active
 
// route match, like on exception responses.
 
if ($this->routeMatch->getRouteName()) {
 
$url = Url::fromRouteMatch($this->routeMatch);
 
return ($url->getRouteName() && '/' . $url->getInternalPath() === $this->getFrontPagePath());
 
}
 
return FALSE;
 
}
 
/**
/**
* Gets the current front page path.
* Gets the current front page path.
*
*
Loading