public function RedirectSubscriber::redirectSearchWithPrefilledExposedFilters in Open Social 8.6
Same name and namespace in other branches
- 8.9 modules/social_features/social_search/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_search\EventSubscriber\RedirectSubscriber::redirectSearchWithPrefilledExposedFilters()
- 8.7 modules/social_features/social_search/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_search\EventSubscriber\RedirectSubscriber::redirectSearchWithPrefilledExposedFilters()
- 8.8 modules/social_features/social_search/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_search\EventSubscriber\RedirectSubscriber::redirectSearchWithPrefilledExposedFilters()
- 10.3.x modules/social_features/social_search/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_search\EventSubscriber\RedirectSubscriber::redirectSearchWithPrefilledExposedFilters()
- 10.0.x modules/social_features/social_search/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_search\EventSubscriber\RedirectSubscriber::redirectSearchWithPrefilledExposedFilters()
- 10.1.x modules/social_features/social_search/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_search\EventSubscriber\RedirectSubscriber::redirectSearchWithPrefilledExposedFilters()
- 10.2.x modules/social_features/social_search/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_search\EventSubscriber\RedirectSubscriber::redirectSearchWithPrefilledExposedFilters()
This method is called when the KernelEvents::REQUEST event is dispatched.
Parameters
\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: The event.
File
- modules/
social_features/ social_search/ src/ EventSubscriber/ RedirectSubscriber.php, line 90
Class
- RedirectSubscriber
- Class RedirectSubscriber.
Namespace
Drupal\social_search\EventSubscriberCode
public function redirectSearchWithPrefilledExposedFilters(GetResponseEvent $event) {
$routeMatch = [
'view.search_users.page_no_value',
'view.search_users.page',
];
if (!in_array($this->currentRoute
->getRouteName(), $routeMatch)) {
return;
}
if ($this->requestStack
->getCurrentRequest() === NULL) {
return;
}
$query = $this->requestStack
->getCurrentRequest()->query
->all();
// Workaround for drupal.org issue #3085806.
if (empty($query) || empty($query['created_op'])) {
$query = [
'created_op' => '<',
];
$parameters = $this->currentRoute
->getParameters();
$currentUrl = Url::fromRoute($this->currentRoute
->getRouteName());
if (!empty($parameters
->get('keys'))) {
$currentUrl = Url::fromRoute($this->currentRoute
->getRouteName(), [
'keys' => $parameters
->get('keys'),
]);
}
$redirect_path = $currentUrl
->toString();
$redirect = Url::fromUserInput($redirect_path, [
'query' => $query,
]);
$event
->setResponse(new RedirectResponse($redirect
->toString()));
}
}