Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. File.php

function File::renderLink

Prepares link to the file.

Parameters

string $data: The XSS safe string for the link text.

\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.

Return value

string Returns a string for the link text.

1 call to File::renderLink()
File::render in core/modules/file/src/Plugin/views/field/File.php
Renders the field.

File

core/modules/file/src/Plugin/views/field/File.php, line 97

Class

File
Field handler to provide simple renderer that allows linking to a file.

Namespace

Drupal\file\Plugin\views\field

Code

protected function renderLink($data, ResultRow $values) {
    if (!empty($this->options['link_to_file']) && $data !== NULL && $data !== '') {
        $this->options['alter']['make_link'] = TRUE;
        $this->options['alter']['url'] = $this->fileUrlGenerator
            ->generate($this->getValue($values, 'uri'));
    }
    return $data;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal