You are here

public function PathProcessorSearchApiPage::processInbound in Search API Pages 8

Processes the inbound path.

Implementations may make changes to the request object passed in but should avoid all other side effects. This method can be called to process requests other than the current request.

Parameters

string $path: The path to process, with a leading slash.

\Symfony\Component\HttpFoundation\Request $request: The HttpRequest object representing the request to process. Note, if this method is being called via the path_processor_manager service and is not part of routing, the current request object must be cloned before being passed in.

Return value

string The processed path.

Overrides InboundPathProcessorInterface::processInbound

File

src/PathProcessor/PathProcessorSearchApiPage.php, line 52

Class

PathProcessorSearchApiPage
Class PathProcessorSearchApiPage.

Namespace

Drupal\search_api_page\PathProcessor

Code

public function processInbound($path, Request $request) {
  foreach ($this
    ->getSearchApiPagePathsUsingCleanUrls() as $search_api_clean_url_path) {
    $regex = '~^' . $search_api_clean_url_path . '~';
    if (preg_match($regex, $path)) {
      $keys = str_replace($search_api_clean_url_path, '', $path);
      return $search_api_clean_url_path . rawurlencode($keys);
    }
  }
  return $path;
}