You are here

public function PathMatcher::match in Acquia Lift Connector 8.3

Same name and namespace in other branches
  1. 8.4 src/Service/Helper/PathMatcher.php \Drupal\acquia_lift\Service\Helper\PathMatcher::match()
  2. 8 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 47

Class

PathMatcher

Namespace

Drupal\acquia_lift\Service\Helper

Code

public function match($path, $path_patterns) {

  // Convert path to lowercase and match.
  $converted_path = mb_strtolower($path);
  $converted_path_patterns = mb_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 = mb_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;
}