SearchPageListBuilder::getDefaultOperations

public SearchPageListBuilder::getDefaultOperations(EntityInterface $entity)

Gets this list's default operations.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the operations are for.

Return value

array The array structure is identical to the return value of self::getOperations().

Overrides ConfigEntityListBuilder::getDefaultOperations

File

core/modules/search/src/SearchPageListBuilder.php, line 296

Class

SearchPageListBuilder
Defines a class to build a listing of search page entities.

Namespace

Drupal\search

Code

public function getDefaultOperations(EntityInterface $entity) {
  /** @var $entity \Drupal\search\SearchPageInterface */
  $operations = parent::getDefaultOperations($entity);

  // Prevent the default search from being disabled or deleted.
  if ($entity->isDefaultSearch()) {
    unset($operations['disable'], $operations['delete']);
  }
  else {
    $operations['default'] = array(
      'title' => $this->t('Set as default'),
      'url' => Url::fromRoute('entity.search_page.set_default', [
        'search_page' => $entity->id(),
      ]),
      'weight' => 50,
    );
  }

  return $operations;
}
doc_Drupal
2016-10-29 09:40:41
Comments
Leave a Comment

Please login to continue.