You are here

protected function TFTController::link in Taxonomy File Tree 3.x

Same name and namespace in other branches
  1. 8 src/Controller/TFTController.php \Drupal\tft\Controller\TFTController::link()

Format a folder or file link.

Return value

array Render array with the formatted link

1 call to TFTController::link()
TFTController::get_content in src/Controller/TFTController.php
Returns folder content.

File

src/Controller/TFTController.php, line 35

Class

TFTController
Class TFTController.

Namespace

Drupal\tft\Controller

Code

protected function link($item, $mime, $type = NULL) {
  if ($mime == 'folder') {
    return [
      'data' => [
        '#type' => 'link',
        '#title' => Markup::create('<i class="fi fi-rr-folder"></i>' . $item['name']),
        '#url' => Url::fromUri("internal:#term/{$item['id']}"),
        '#attributes' => [
          'class' => 'folder-folder-link',
          'id' => "tid-{$item['id']}",
        ],
      ],
    ];
  }
  else {
    $icon_class = file_icon_class($mime);
    return [
      'data' => [
        '#type' => 'link',
        '#title' => Markup::create('<i class="fi fi-rr-file"></i>' . $item['name']),
        '#url' => Url::fromUri("internal:/tft/download/file/{$item['id']}"),
        '#attributes' => [
          'class' => "file {$icon_class} folder-folder-link",
          'target' => '_blank',
        ],
      ],
    ];
  }
}