public function checkLink($link_hash, $paragraph_id) {
    // Load file and paragraph.
    $entity = $this->getSubscribeFileEntity('link_hash', $link_hash);
    $this->checkLinkActive($entity);
    $paragraph = Paragraph::load($paragraph_id);
    $file_hash = $entity->get('file_hash')->get(0)->getValue();
    $link_options = [
      'absolute' => TRUE,
      'attributes' => ['class' => 'btn btn-primary btn-orange']
    ];

    // Generate download link/
    $button_text = $paragraph->get('field_d_p_sf_download_button')->getValue();
    $download_link = Link::createFromRoute($button_text[0]['value'], 'd_p_subscribe_file.downloadfile.getFile', ['file_hash' => $file_hash['value']], $link_options);
    $rendered_download_link = $download_link->toString()->getGeneratedLink();

    // Generate download page with link.
    $display_settings = ['label' => 'hidden',];
    $body = $paragraph->get('field_d_p_sf_download_page')->view($display_settings);
    $body[0]['#text'] = str_replace("[download-button]", $rendered_download_link, $body[0]['#text']);
    return [
      '#theme' => 'd_p_subscribe_file_download_page',
      '#body' => $body,
    ];
  }
public function checkLink($link_hash, $paragraph_id) {
    // Load file and paragraph.
    $entity = $this->getSubscribeFileEntity('link_hash', $link_hash);
    $this->checkLinkActive($entity);
    $paragraph = Paragraph::load($paragraph_id);
    $file_hash = $entity->get('file_hash')->get(0)->getValue();
    $link_options = [
      'absolute' => TRUE,
      'attributes' => ['class' => 'btn btn-primary btn-orange']
    ];

    // Generate download link/
    $button_text = $paragraph->get('field_d_p_sf_download_button')->getValue();
    $download_link = Link::createFromRoute($button_text[0]['value'], 'd_p_subscribe_file.downloadfile.getFile', ['file_hash' => $file_hash['value']], $link_options);
    $rendered_download_link = $download_link->toString()->getGeneratedLink();

    // Generate download page with link.
    $display_settings = ['label' => 'hidden',];
    $body = $paragraph->get('field_d_p_sf_download_page')->view($display_settings);
    $body[0]['#text'] = str_replace("[download-button]", $rendered_download_link, $body[0]['#text']);
    return [
      '#theme' => 'd_p_subscribe_file_download_page',
      '#body' => $body,
    ];
  }
public function checkLink ( $ link_hash , $ paragraph_id ) { // Load file and paragraph. $ entity = $ this -> getSubscribeFileEntity ( 'link_hash' , $ link_hash ) ; $ this -> checkLinkActive ( $ entity ) ; $ paragraph = Paragraph :: load ( $ paragraph_id ) ; $ file_hash = $ entity -> get ( 'file_hash' ) -> get ( 0 ) -> getValue ( ) ; $ link_options = [ 'absolute' => TRUE , 'attributes' => [ 'class' => 'btn btn-primary btn-orange' ] ] ; // Generate download link/ $ button_text = $ paragraph -> get ( 'field_d_p_sf_download_button' ) -> getValue ( ) ; $ download_link = Link :: createFromRoute ( $ button_text [ 0 ] [ 'value' ] , 'd_p_subscribe_file.downloadfile.getFile' , [ 'file_hash' => $ file_hash [ 'value' ] ] , $ link_options ) ; $ rendered_download_link = $ download_link -> toString ( ) -> getGeneratedLink ( ) ; // Generate download page with link. $ display_settings = [ 'label' => 'hidden' , ] ; $ body = $ paragraph -> get ( 'field_d_p_sf_download_page' ) -> view ( $ display_settings ) ; $ body [ 0 ] [ '#text' ] = str_replace ( "[download-button]" , $ rendered_download_link , $ body [ 0 ] [ '#text' ] ) ; return [ '#theme' => 'd_p_subscribe_file_download_page' , '#body' => $ body , ] ; }
Check link to download file.

@param string $link_hash
Link Hash.
@param string $paragraph_id
Paragraph id.

@return array
Render download page.
Check link to download file .