Skip to content
Snippets Groups Projects

Release 5.0.0

Merged Georgi requested to merge release_5.0.0 into master
3 files
+ 11
104
Compare changes
  • Side-by-side
  • Inline
Files
3
<?php
namespace SGalinski\SgRoutes\Middleware;
/**
*
* Copyright notice
*
* (c) sgalinski Internet Services (https://www.sgalinski.de)
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
*/
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
use Psr\Http\Server\RequestHandlerInterface;
use SGalinski\SgRoutes\Service\DemoModeService;
use SGalinski\SgRoutes\Service\LicenceCheckService;
use TYPO3\CMS\Core\Http\Response;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
/**
* Resolver for generating frontend links
*
* @package SGalinski\SgRoutes\Middleware
* @author Kevin Ditscheid <kevin.ditscheid@sgalinski.de>
*/
class FrontendLinkResolver implements MiddlewareInterface {
/**
* Process an incoming server request.
*
* Processes an incoming server request in order to produce a response.
* If unable to produce the response itself, it may delegate to the provided
* request handler to do so.
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface {
if (!LicenceCheckService::hasValidLicense() && !DemoModeService::isInDemoMode()) {
return $handler->handle($request);
}
$queryParams = $request->getQueryParams();
if (!isset($queryParams['tx_sgroutes_frontendlink'])) {
return $handler->handle($request);
}
$contentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class);
$response = new Response();
$response->getBody()
->write(
$contentObjectRenderer->typoLink(
'',
[
'parameter' => $queryParams['tx_sgroutes_frontendlink']['destination_url'],
'returnLast' => 'url'
]
)
);
return $response;
}
}
Loading