You are here

public function DocumentsLastGroupBlock::itemLink in Opigno Learning path 3.x

Create a download link fr files adn view for folder.

1 call to DocumentsLastGroupBlock::itemLink()
DocumentsLastGroupBlock::build in src/Plugin/Block/DocumentsLastGroupBlock.php
Builds and returns the renderable array for this block plugin.

File

src/Plugin/Block/DocumentsLastGroupBlock.php, line 51

Class

DocumentsLastGroupBlock
Provides a documentslastgroupblock block.

Namespace

Drupal\opigno_learning_path\Plugin\Block

Code

public function itemLink($item) {
  if ($item["type"] == 'file') {
    $tft_url = Url::fromUri("internal:/tft/download/file/{$item['id']}")
      ->toString();
  }
  else {
    $tft_url = Url::fromRoute('tft.group', [
      'group' => $this->groupId,
    ], [
      'fragment' => "term/{$item['id']}",
    ])
      ->toString();
  }
  return $tft_url;
}