You are here

public function SolrAdminCloudAccessCheck::access in Search API Solr 4.x

A custom access check.

Parameters

\Drupal\Core\Session\AccountInterface $account: Run access checks for this account.

\Drupal\search_api\ServerInterface|null $search_api_server: (optional) The Search API server entity.

File

modules/search_api_solr_admin/src/Access/SolrAdminCloudAccessCheck.php, line 24

Class

SolrAdminCloudAccessCheck
Provides an access check for the "Solr Admin" routes for Solr Cloud.

Namespace

Drupal\search_api_solr_admin\Access

Code

public function access(AccountInterface $account, ServerInterface $search_api_server = NULL) {
  if ($search_api_server) {
    $backend = $search_api_server
      ->getBackend();
    if ($backend instanceof SolrBackendInterface) {
      if ($backend
        ->getSolrConnector()
        ->isCloud()) {
        return AccessResult::allowed();
      }
    }
  }
  return AccessResult::forbidden();
}