You are here

public function EntityOperations::render in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/field/EntityOperations.php \Drupal\views\Plugin\views\field\EntityOperations::render()
  2. 9 core/modules/views/src/Plugin/views/field/EntityOperations.php \Drupal\views\Plugin\views\field\EntityOperations::render()

File

core/modules/views/src/Plugin/views/field/EntityOperations.php, line 129

Class

EntityOperations
Renders all operations links for an entity.

Namespace

Drupal\views\Plugin\views\field

Code

public function render(ResultRow $values) {
  $entity = $this
    ->getEntityTranslation($this
    ->getEntity($values), $values);
  $operations = $this->entityTypeManager
    ->getListBuilder($entity
    ->getEntityTypeId())
    ->getOperations($entity);
  if ($this->options['destination']) {
    foreach ($operations as &$operation) {
      if (!isset($operation['query'])) {
        $operation['query'] = [];
      }
      $operation['query'] += $this
        ->getDestinationArray();
    }
  }
  $build = [
    '#type' => 'operations',
    '#links' => $operations,
  ];
  return $build;
}