You are here

public function TranslationOperationsField::render in Translation Views 8

Build operation links.

Overrides EntityOperations::render

File

src/Plugin/views/field/TranslationOperationsField.php, line 81

Class

TranslationOperationsField
Renders translation operations links.

Namespace

Drupal\translation_views\Plugin\views\field

Code

public function render(ResultRow $values) {

  /* @var \Drupal\Core\Entity\ContentEntityInterface $entity */
  $entity = $this
    ->getEntity($values);
  $langcode_key = $this
    ->buildSourceEntityLangcodeKey($entity);
  $source_langcode = $values->{$langcode_key};
  $operations = $this
    ->getTranslationOperations($entity, $source_langcode);
  if ($this->options['destination']) {
    foreach ($operations as &$operation) {
      if (!isset($operation['query'])) {
        $operation['query'] = [];
      }
      $operation['query'] += $this
        ->getDestinationArray();
    }
  }
  $build = [
    '#type' => 'operations',
    '#links' => $operations,
  ];
  $build['#cache']['contexts'][] = 'url.query_args:target_language';
  return $build;
}