Skip to content

Commit

Permalink
Add middleware as replacement for isOutputting hook in v11
Browse files Browse the repository at this point in the history
  • Loading branch information
nhovratov authored and maechler committed Oct 31, 2021
1 parent 71331bb commit 5db08f7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Classes/Middleware/PdfViewHelpersStopOutputMiddleware.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Bithost\Pdfviewhelpers\Middleware;

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Http\NullResponse;

class PdfViewHelpersStopOutputMiddleware implements MiddlewareInterface
{
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$response = $handler->handle($request);
if ($GLOBALS['TSFE']->applicationData['tx_pdfviewhelpers']['pdfOutput'] ?? false) {
return new NullResponse();
}
return $response;
}
}
10 changes: 10 additions & 0 deletions Configuration/RequestMiddlewares.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

return [
'frontend' => [
'pdfviewhelpers' => [
'target' => \Bithost\Pdfviewhelpers\Middleware\PdfViewHelpersStopOutputMiddleware::class,
'after' => 'typo3/cms-frontend/page-argument-validator'
]
]
];

0 comments on commit 5db08f7

Please sign in to comment.