function EntityOperations::render

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/field/EntityOperations.php \Drupal\views\Plugin\views\field\EntityOperations::render()
  2. 10 core/modules/views/src/Plugin/views/field/EntityOperations.php \Drupal\views\Plugin\views\field\EntityOperations::render()
  3. 11.x core/modules/views/src/Plugin/views/field/EntityOperations.php \Drupal\views\Plugin\views\field\EntityOperations::render()

Overrides FieldPluginBase::render

File

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

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.