Skip to content

Commit

Permalink
D002-testing: Add another page for demoing the DownloadController fun…
Browse files Browse the repository at this point in the history
…ctionality.
  • Loading branch information
abel-santos-corral committed May 15, 2024
1 parent 142e9b6 commit cea0292
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/modules/responses/responses.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,16 @@ responses.example_plain_html:
# This is a test page, hence no access check is needed.
_access: 'TRUE'
responses.pdf_download:
path: /pdf-download
path: '/pdf-download'
defaults:
_controller: Drupal\responses\Controller\DownloadController::page
requirements:
_user_is_logged_in: 'TRUE'

responses.download_page:
path: '/pdf-download-page'
defaults:
_title: 'Download Page'
_controller: '\Drupal\responses\Controller\DownloadPageController'
requirements:
_permission: 'access content'
26 changes: 26 additions & 0 deletions lib/modules/responses/src/Controller/DownloadPageController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php declare(strict_types = 1);

namespace Drupal\responses\Controller;

use Drupal\Core\Controller\ControllerBase;

/**
* Returns responses for Responses routes.
*/
final class DownloadPageController extends ControllerBase {

/**
* Builds the response.
*/
public function __invoke(): array {

$build['content'] = [
'#type' => 'item',
'#markup' => '<p>' . $this->t('Click on button to download example pdf') . '</p></br>'
. '<a class="button--primary button" href="pdf-download" target="_blank">' . $this->t('Download') . '</a>',
];

return $build;
}

}

0 comments on commit cea0292

Please sign in to comment.