You are here

protected function QueryString::getRequestByFacetSourcePath in Facets 8

Gets a request object based on the facet source path.

If the facet's source has a path, we construct a request object based on that path, as it may be different than the current request's. This method statically caches the request object based on the facet source path so that subsequent calls to this processer do not recreate the same request object.

Parameters

string $facet_source_path: The facet source path.

Return value

\Symfony\Component\HttpFoundation\Request The request.

1 call to QueryString::getRequestByFacetSourcePath()
QueryString::buildUrls in src/Plugin/facets/url_processor/QueryString.php
Adds urls to the results.

File

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

Class

QueryString
Query string URL processor.

Namespace

Drupal\facets\Plugin\facets\url_processor

Code

protected function getRequestByFacetSourcePath($facet_source_path) {
  $requestsByPath =& drupal_static(__CLASS__ . __FUNCTION__, []);
  if (!$facet_source_path) {
    return $this->request;
  }
  if (array_key_exists($facet_source_path, $requestsByPath)) {
    return $requestsByPath[$facet_source_path];
  }
  $request = Request::create($facet_source_path);
  $request->attributes
    ->set('_format', $this->request
    ->get('_format'));
  $requestsByPath[$facet_source_path] = $request;
  return $request;
}