Skip to content

Commit

Permalink
[TASK] Cleanup and deprecatiion fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rickymathewkweb committed Jul 16, 2020
1 parent 361a133 commit 4479695
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions Classes/Middleware/PdfRender.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,9 @@
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Http\JsonResponse;
use TYPO3\CMS\Core\Http\Response;
use TYPO3\CMS\Core\Utility\GeneralUtility;


/**
* Middleware provides generation of full html page as PDF
* @author Ricky Mathew <[email protected]>
Expand All @@ -53,12 +49,12 @@ class PdfRender implements MiddlewareInterface
*/
protected $view;


/**
* Instantiates necessary objects
*
*/
public function __construct() {
public function __construct()
{
$this->objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$this->view = $this->objectManager->get('Mittwald\\Web2pdf\View\\PdfView');
}
Expand All @@ -68,9 +64,12 @@ public function __construct() {
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
//TODO set condition to distinguidh pdf rendering request also need to pass the page title as second parameter in renderHtmlOutput()
$this->view->renderHtmlOutput($GLOBALS['TSFE']->content,'');
$arguments = $request->getQueryParams();
if (isset($arguments['tx_web2pdf_pi1']) && $arguments['tx_web2pdf_pi1']['argument'] == 'printPage') {
$response = $handler->handle($request);
$this->view->renderHtmlOutput($GLOBALS['TSFE']->pageRenderer->getBodyContent(),$GLOBALS['TSFE']->page['title']);
}
return $handler->handle($request);
}

}
}
2 changes: 1 addition & 1 deletion Configuration/RequestMiddlewares.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'web2pdf/PdfRender' => [
'target' => \Mittwald\Web2pdf\Middleware\PdfRender::class,
'after' => [
'typo3/cms-frontend/prepare-tsfe-rendering',
'typo3/cms-frontend/output-compression',
]
],
],
Expand Down

0 comments on commit 4479695

Please sign in to comment.