Last active
December 28, 2016 12:09
-
-
Save woutersf/08558c57f4bebe252611ef8a787cfff4 to your computer and use it in GitHub Desktop.
D8 Match a canonical route
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//If is frontpage | |
$on_frontpage = \Drupal::service('path.matcher')->isFrontPage(); | |
//Match canonical route | |
$route_match = \Drupal::routeMatch(); | |
if ($route_match->getRouteName() == 'entity.node.canonical') { | |
// Do something.. | |
} | |
// Match alias | |
$current_path = \Drupal::service('path.current')->getPath(); | |
if($current_path == '/user/login') { | |
// Do something.. | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment