You are here

public function ServerController::serverBypassEnable in Search API 8

Enables a search server without a confirmation form.

Parameters

\Drupal\search_api\ServerInterface $search_api_server: The server to be enabled.

Return value

\Symfony\Component\HttpFoundation\Response The response to send to the browser.

1 string reference to 'ServerController::serverBypassEnable'
search_api.routing.yml in ./search_api.routing.yml
search_api.routing.yml

File

src/Controller/ServerController.php, line 108

Class

ServerController
Provides block routines for search server-specific routes.

Namespace

Drupal\search_api\Controller

Code

public function serverBypassEnable(ServerInterface $search_api_server) {
  $search_api_server
    ->setStatus(TRUE)
    ->save();

  // Notify the user about the status change.
  $this
    ->getMessenger()
    ->addStatus($this
    ->t('The search server %name has been enabled.', [
    '%name' => $search_api_server
      ->label(),
  ]));

  // Redirect to the server's "View" page.
  $url = $search_api_server
    ->toUrl('canonical');
  return $this
    ->redirect($url
    ->getRouteName(), $url
    ->getRouteParameters());
}