You are here

protected function EntityListBuilder::getDefaultOperations in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/EntityListBuilder.php \Drupal\Core\Entity\EntityListBuilder::getDefaultOperations()
  2. 9 core/lib/Drupal/Core/Entity/EntityListBuilder.php \Drupal\Core\Entity\EntityListBuilder::getDefaultOperations()

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().

3 calls to EntityListBuilder::getDefaultOperations()
ConfigEntityListBuilder::getDefaultOperations in core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php
Gets this list's default operations.
EntityListBuilder::getOperations in core/lib/Drupal/Core/Entity/EntityListBuilder.php
Provides an array of information to build a list of operation links.
WorkspaceListBuilder::getDefaultOperations in core/modules/workspaces/src/WorkspaceListBuilder.php
Gets this list's default operations.
2 methods override EntityListBuilder::getDefaultOperations()
ConfigEntityListBuilder::getDefaultOperations in core/lib/Drupal/Core/Config/Entity/ConfigEntityListBuilder.php
Gets this list's default operations.
WorkspaceListBuilder::getDefaultOperations in core/modules/workspaces/src/WorkspaceListBuilder.php
Gets this list's default operations.

File

core/lib/Drupal/Core/Entity/EntityListBuilder.php, line 130

Class

EntityListBuilder
Defines a generic implementation to build a listing of entities.

Namespace

Drupal\Core\Entity

Code

protected function getDefaultOperations(EntityInterface $entity) {
  $operations = [];
  if ($entity
    ->access('update') && $entity
    ->hasLinkTemplate('edit-form')) {
    $operations['edit'] = [
      'title' => $this
        ->t('Edit'),
      'weight' => 10,
      'url' => $this
        ->ensureDestination($entity
        ->toUrl('edit-form')),
    ];
  }
  if ($entity
    ->access('delete') && $entity
    ->hasLinkTemplate('delete-form')) {
    $operations['delete'] = [
      'title' => $this
        ->t('Delete'),
      'weight' => 100,
      'url' => $this
        ->ensureDestination($entity
        ->toUrl('delete-form')),
    ];
  }
  return $operations;
}