You are here

public function UltimenuTool::isPageMatch in Ultimenu 8.2

Checks if the visible pages match the current path.

1 call to UltimenuTool::isPageMatch()
UltimenuTool::isAllowedBlock in src/UltimenuTool.php
Checks if user has access to view a block, including its path visibility.

File

src/UltimenuTool.php, line 316

Class

UltimenuTool
Provides Ultimenu utility methods.

Namespace

Drupal\ultimenu

Code

public function isPageMatch(EntityInterface $block, array $config = []) {
  $page_match = FALSE;
  if ($pages = $this
    ->getVisiblePages($block)) {
    $path = $config['current_path'];
    $langcode = $this->languageManager
      ->getCurrentLanguage()
      ->getId();
    $path_check = $this->aliasRepository
      ->lookupByAlias($path, $langcode);
    $path_alias = mb_strtolower($path_check['alias']);
    $page_match = $this->pathMatcher
      ->matchPath($path_alias, $pages);
    if ($path_alias != $path) {
      $page_match = $page_match || $this->pathMatcher
        ->matchPath($path, $pages);
    }
  }
  return $page_match;
}