You are here

public function AbstractSolrEntityController::enableOnServer in Search API Solr 8.3

Same name and namespace in other branches
  1. 4.x src/Controller/AbstractSolrEntityController.php \Drupal\search_api_solr\Controller\AbstractSolrEntityController::enableOnServer()

Enables a Solr Entity on this server.

Parameters

\Drupal\search_api\ServerInterface $search_api_server: Search API server.

\Drupal\search_api_solr\SolrConfigInterface $solr_entity: Solr entity.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse Redirect response.

Throws

\Drupal\Core\Entity\EntityMalformedException

\Drupal\Core\Entity\EntityStorageException

4 calls to AbstractSolrEntityController::enableOnServer()
SolrCacheController::enableOnServer in src/Controller/SolrCacheController.php
Enables a Solr Entity on this server.
SolrFieldTypeController::enableOnServer in src/Controller/SolrFieldTypeController.php
Enables a Solr Entity on this server.
SolrRequestDispatcherController::enableOnServer in src/Controller/SolrRequestDispatcherController.php
Enables a Solr Entity on this server.
SolrRequestHandlerController::enableOnServer in src/Controller/SolrRequestHandlerController.php
Enables a Solr Entity on this server.
4 methods override AbstractSolrEntityController::enableOnServer()
SolrCacheController::enableOnServer in src/Controller/SolrCacheController.php
Enables a Solr Entity on this server.
SolrFieldTypeController::enableOnServer in src/Controller/SolrFieldTypeController.php
Enables a Solr Entity on this server.
SolrRequestDispatcherController::enableOnServer in src/Controller/SolrRequestDispatcherController.php
Enables a Solr Entity on this server.
SolrRequestHandlerController::enableOnServer in src/Controller/SolrRequestHandlerController.php
Enables a Solr Entity on this server.

File

src/Controller/AbstractSolrEntityController.php, line 123

Class

AbstractSolrEntityController
Provides different listings of Solr Entities.

Namespace

Drupal\search_api_solr\Controller

Code

public function enableOnServer(ServerInterface $search_api_server, SolrConfigInterface $solr_entity) {
  $disabled_key = $solr_entity
    ->getEntityType()
    ->getKey('disabled');
  $backend_config = $search_api_server
    ->getBackendConfig();
  $backend_config[$disabled_key] = array_values(array_diff($backend_config[$disabled_key], [
    $solr_entity
      ->id(),
  ]));
  $search_api_server
    ->setBackendConfig($backend_config);
  $search_api_server
    ->save();
  return new RedirectResponse($solr_entity
    ->toUrl('collection')
    ->toString());
}