You are here

public function AbstractSolrEntityListBuilder::getDefaultOperations in Search API Solr 4.x

Same name and namespace in other branches
  1. 8.3 src/Controller/AbstractSolrEntityListBuilder.php \Drupal\search_api_solr\Controller\AbstractSolrEntityListBuilder::getDefaultOperations()

Throws

\Drupal\Core\Entity\EntityMalformedException

Overrides ConfigEntityListBuilder::getDefaultOperations

File

src/Controller/AbstractSolrEntityListBuilder.php, line 127

Class

AbstractSolrEntityListBuilder
Provides a listing of Solr Entities.

Namespace

Drupal\search_api_solr\Controller

Code

public function getDefaultOperations(EntityInterface $solr_entity) {

  /** @var \Drupal\search_api_solr\SolrConfigInterface $solr_entity */
  $operations = parent::getDefaultOperations($solr_entity);
  unset($operations['delete']);
  if (!$solr_entity->disabledOnServer && $solr_entity
    ->access('view') && $solr_entity
    ->hasLinkTemplate('disable-for-server')) {
    $operations['disable_for_server'] = [
      'title' => $this
        ->t('Disable'),
      'weight' => 10,
      'url' => $solr_entity
        ->toUrl('disable-for-server'),
    ];
  }
  if ($solr_entity->disabledOnServer && $solr_entity
    ->access('view') && $solr_entity
    ->hasLinkTemplate('enable-for-server')) {
    $operations['enable_for_server'] = [
      'title' => $this
        ->t('Enable'),
      'weight' => 10,
      'url' => $solr_entity
        ->toUrl('enable-for-server'),
    ];
  }
  return $operations;
}