Problem/Motivation

We want to remove include files (including path.inc) and move from procedural to OO code.

Proposed resolution

Move drupal_is_front_page() to the PathMatcher service.

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kim.pepper’s picture

Status: Active » Needs review
FileSize
3.53 KB

An initial patch to get things going...

kim.pepper’s picture

FileSize
3.53 KB
808 bytes

Slight flaw in my logic there. Should be checking if property is set, not its value.

   public function isFrontPage() {
     // Cache the result as this is called often.
-    if (!$this->isCurrentFrontPage) {
+    if (!isset($this->isCurrentFrontPage)) {
       $this->isCurrentFrontPage = (current_path() == $this->getFrontPagePath());
     }

dawehner’s picture

+++ b/core/lib/Drupal/Core/Path/PathMatcher.php
@@ -67,11 +70,37 @@ public function matchPath($path, $patterns) {
+    if (!isset($this->isCurrentFrontPage)) {
+      $this->isCurrentFrontPage = (current_path() == $this->getFrontPagePath());
+    }

mh. One thing we might should do instead is the following: Change the configuration to internally store a route name + parameters and compare it with the one of the current route match object. Do you have an oppinion?

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Otherwise we could for sure just to that in a dedicated issue.

ParisLiakos’s picture

yes #3 is a great followup
rtbc++

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 3cfff37 and pushed to 8.x. Thanks!

  • alexpott committed 3cfff37 on 8.x
    Issue #2301975 by kim.pepper: Move drupal_is_front_page to PathMatcher...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.