Skip to content

Commit

Permalink
[TASK] Fixed property promotion in MiddlewareTest Class
Browse files Browse the repository at this point in the history
  • Loading branch information
hojalatheef committed Nov 22, 2024
1 parent d9c93b2 commit 505f8e0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
10 changes: 2 additions & 8 deletions Classes/Helper/ReplacerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use JWeiland\Replacer\Configuration\ReplaceConfiguration;
use JWeiland\Replacer\Enumeration\ConfigurationTypeEnumeration;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -23,14 +24,7 @@
*/
class ReplacerHelper
{
protected TypoScriptHelper $typoScriptHelper;

protected ServerRequestInterface $request;

public function __construct(TypoScriptHelper $typoScriptHelper)
{
$this->typoScriptHelper = $typoScriptHelper;
}
public function __construct(protected TypoScriptHelper $typoScriptHelper) {}

/**
* Search and replace text from $contentToReplace
Expand Down
2 changes: 2 additions & 0 deletions Classes/Helper/TypoScriptHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
namespace JWeiland\Replacer\Helper;

use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;

class TypoScriptHelper
{
Expand Down
12 changes: 2 additions & 10 deletions Classes/Middleware/ReplaceContentMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@
*/
class ReplaceContentMiddleware implements MiddlewareInterface
{
private ReplacerHelper $replacerHelper;

public function __construct(ReplacerHelper $replacerHelper)
{
$this->replacerHelper = $replacerHelper;
}
public function __construct(protected ReplacerHelper $replacerHelper) {}

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
Expand All @@ -55,10 +50,7 @@ protected function getContentObjectRenderer(ServerRequestInterface $request): Co
$tsfeController = $request->getAttribute('frontend.controller');

// Create a new instance of ContentObjectRenderer
$cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class);

// Associate the ContentObjectRenderer with the TypoScriptFrontendController
$cObj->setFrontendController($tsfeController);
$cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class, $tsfeController);

// Set the request in the ContentObjectRenderer
$cObj->setRequest($request);
Expand Down

0 comments on commit 505f8e0

Please sign in to comment.