Manually Checking Path-based Visibility in Drupal 8
This mimics the path visibility settings on block configurations.
1 2 3 4 5 6 7 |
$current_path = \Drupal::service('path.current')->getPath(); $patterns = "/user\n/user/login\n/user/password"; $match = \Drupal::service('path.matcher')->matchPath($current_path, $patterns); if ($match) { $this->doSomething(); } |
2 Comments
Lolandese
Seems like the URL at the end of line 3 in the code snippet is there by mistake.
adam
Ah! Thank you! All fixed.