You are here

ConfigEntityOperations.php in Configuration Views 2.0.x

Same filename and directory in other branches
  1. 8 src/Plugin/views/field/ConfigEntityOperations.php

File

src/Plugin/views/field/ConfigEntityOperations.php
View source
<?php

namespace Drupal\config_views\Plugin\views\field;

use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;

/**
 * Field handler to display entity label optionally linked to entity page.
 *
 * @ViewsField("config_entity_operations")
 */
class ConfigEntityOperations extends FieldPluginBase {

  /**
   * {@inheritdoc}
   */
  public function render(ResultRow $values) {

    // Doesn't work as there is no alias.
    // $value = $this->getValue($values, 'type');.
    $entity_type = $values->type;
    $entity = $values->entity;
    $list_builder = \Drupal::entityTypeManager()
      ->getListBuilder($entity_type);
    return [
      '#type' => 'operations',
      '#links' => $list_builder
        ->getOperations($entity),
    ];
  }

}

Classes

Namesort descending Description
ConfigEntityOperations Field handler to display entity label optionally linked to entity page.