You are here

public function PathMatcher::match in Acquia Lift Connector 8

Same name and namespace in other branches
  1. 8.4 src/Service/Helper/PathMatcher.php \Drupal\acquia_lift\Service\Helper\PathMatcher::match()
  2. 8.3 src/Service/Helper/PathMatcher.php \Drupal\acquia_lift\Service\Helper\PathMatcher::match()

Determine if the path falls into one of the allowed paths (in terms of path patterns).

Parameters

string $path: The actual path that's being matched by.

string $path_patterns: The path patterns that the path is being matched to.

Return value

boolean True if should attach.

File

src/Service/Helper/PathMatcher.php, line 53
Contains \Drupal\acquia_lift\Service\Helper\PathMatcher.

Class

PathMatcher

Namespace

Drupal\acquia_lift\Service\Helper

Code

public function match($path, $path_patterns) {

  // Convert path to lowercase and match.
  $converted_path = Unicode::strtolower($path);
  $converted_path_patterns = Unicode::strtolower($path_patterns);
  if ($this->pathMatcher
    ->matchPath($converted_path, $converted_path_patterns)) {
    return TRUE;
  }

  // Compare the lowercase path alias (if any) and internal path.
  $converted_path_alias = Unicode::strtolower($this->aliasManager
    ->getAliasByPath($converted_path));
  if ($converted_path != $converted_path_alias && $this->pathMatcher
    ->matchPath($converted_path_alias, $converted_path_patterns)) {
    return TRUE;
  }
  return FALSE;
}