You are here

protected function PrettyPathsActiveFilters::getFiltersFromRoute in Facets Pretty Paths 8

Returns the raw string of filters from the current route.

Return value

string|null The raw filters from the URL.

1 call to PrettyPathsActiveFilters::getFiltersFromRoute()
PrettyPathsActiveFilters::getActiveFilters in src/PrettyPathsActiveFilters.php
Returns the active filters for a given Facet source ID.

File

src/PrettyPathsActiveFilters.php, line 159

Class

PrettyPathsActiveFilters
Used for determining the Pretty Paths active filters on a given request.

Namespace

Drupal\facets_pretty_paths

Code

protected function getFiltersFromRoute() {

  // Default pretty path routes have their filters defined as route params.
  if ($this->routeMatch
    ->getParameter('facets_query')) {
    return $this->routeMatch
      ->getParameter('facets_query');
  }

  // When current route is views.ajax, retrieve filters from the real url,
  // defined as GET parameter.
  if ($this->routeMatch
    ->getRouteName() === 'views.ajax') {
    $q = $this->request->query
      ->get('q');
    if ($q) {
      $route_params = Url::fromUserInput($q)
        ->getRouteParameters();
      if (isset($route_params['facets_query'])) {
        return $route_params['facets_query'];
      }
    }
  }
  return NULL;
}