How to check if current page is frontpage in drupal 8
During the Drupal 8 development cycle a
Drupal 7:
path.matcher
was introduced which deprecated most procedural functions in path.incDrupal 7:
$path_matches = drupal_match_path($path, $patterns);
$is_front = drupal_is_front_page();
Drupal 8:$path_matches = \Drupal::service('path.matcher')->matchPath($path, $patterns) ;
$is_front = \Drupal::service('path.matcher')->isFrontPage();
reff links:
https://www.drupal.org/node/2274675
Deprecated by path.matcher service.
https://www.drupal.org/node/2274675
Example use case in druapl 7
if (path_is_admin(current_path())) { // Do stuff. }