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

Files: 
CommentFileSizeAuthor
#2 interdiff.txt808 byteskim.pepper
#2 2301975-front-page-2.patch3.53 KBkim.pepper
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 73,373 pass(es). View
#1 2301975-front-page-1.patch3.53 KBkim.pepper
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 73,226 pass(es). View

Comments

kim.pepper’s picture

Status: Active » Needs review
FileSize
3.53 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 73,226 pass(es). View

An initial patch to get things going...

kim.pepper’s picture

FileSize
3.53 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 73,373 pass(es). View
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.