From 4f1f60f42aa828d5ef10a0a39dc1be487664e49f Mon Sep 17 00:00:00 2001 From: Liam Morland <lkmorlan@uwaterloo.ca> Date: Tue, 26 Jan 2021 10:27:27 -0500 Subject: [PATCH] ISTWCMS-4229: Create UWService::nodeIsHomePage() --- src/Service/UWService.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Service/UWService.php b/src/Service/UWService.php index 362e36d1..e9369108 100644 --- a/src/Service/UWService.php +++ b/src/Service/UWService.php @@ -368,4 +368,19 @@ class UWService implements UWServiceInterface { } } + /** + * Determine whether a node is the home page. + * + * @param int $nid + * A node ID. + * + * @return bool + * TRUE when the node is the home page, FALSE otherwise. + */ + public static function nodeIsHomePage(int $nid): bool { + $front_page_path = \Drupal::configFactory()->get('system.site')->get('page.front'); + $node_alias = \Drupal::service('path_alias.manager')->getAliasByPath('/node/' . $nid); + return $front_page_path === $node_alias; + } + } -- GitLab