-
Manually Checking Path-based Visibility in Drupal 8
This mimics the path visibility settings on block configurations.
1234567$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();}