You are here

protected function QueryString::getFacetIdByUrlAlias in Facets 8

Gets the facet id from the url alias & facet source id.

Parameters

string $url_alias: The url alias.

string $facet_source_id: The facet source id.

Return value

bool|string Either the facet id, or FALSE if that can't be loaded.

1 call to QueryString::getFacetIdByUrlAlias()
QueryString::initializeActiveFilters in src/Plugin/facets/url_processor/QueryString.php
Initializes the active filters from the request query.

File

src/Plugin/facets/url_processor/QueryString.php, line 365

Class

QueryString
Query string URL processor.

Namespace

Drupal\facets\Plugin\facets\url_processor

Code

protected function getFacetIdByUrlAlias($url_alias, $facet_source_id) {
  $mapping =& drupal_static(__FUNCTION__);
  if (!isset($mapping[$facet_source_id][$url_alias])) {
    $storage = $this->entityTypeManager
      ->getStorage('facets_facet');
    $facet = current($storage
      ->loadByProperties([
      'url_alias' => $url_alias,
      'facet_source_id' => $facet_source_id,
    ]));
    if (!$facet) {
      return NULL;
    }
    $mapping[$facet_source_id][$url_alias] = $facet
      ->id();
  }
  return $mapping[$facet_source_id][$url_alias];
}