Skip to content
Snippets Groups Projects
Commit 4f1f60f4 authored by Liam Morland's avatar Liam Morland
Browse files

ISTWCMS-4229: Create UWService::nodeIsHomePage()

parent 6db4c581
No related branches found
No related tags found
1 merge request!34ISTWCMS-4229: Prevent moderation of home page except by admin
...@@ -368,4 +368,19 @@ class UWService implements UWServiceInterface { ...@@ -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;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment