public function TranslationLink::render_link

Alters the field to render a link.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity being rendered.

\stdClass $values: The current row of the views result.

Return value

string The acutal rendered text (without the link) of this field.

1 call to TranslationLink::render_link()
TranslationLink::render in drupal/core/modules/translation_entity/lib/Drupal/translation_entity/Plugin/views/field/TranslationLink.php
Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::render().

File

drupal/core/modules/translation_entity/lib/Drupal/translation_entity/Plugin/views/field/TranslationLink.php, line 62
Contains \Drupal\translation_entity\Plugin\views\field\TranslationLink.

Class

TranslationLink
Provides a translation link for an entity.

Namespace

Drupal\translation_entity\Plugin\views\field

Code

public function render_link(EntityInterface $entity, \stdClass $values) {
  if (translation_entity_translate_access($entity)) {
    $text = !empty($this->options['text']) ? $this->options['text'] : t('translate');
    $this->options['alter']['make_link'] = TRUE;
    $uri = $entity
      ->uri();
    $this->options['alter']['path'] = $uri['path'] . '/translations';
    return $text;
  }
}