-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
get Query Param text in Searchbar todo (caching Problem)
- Loading branch information
thomas-sc
committed
Oct 9, 2024
1 parent
6df21ae
commit a9cb072
Showing
3 changed files
with
20 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Slub\LisztCommon\ViewHelpers; | ||
|
||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; | ||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Core\Type\File\ImageInfo; | ||
|
||
|
||
|
||
final class GetQueryParamsViewHelper extends AbstractViewHelper | ||
{ | ||
|
||
|
||
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): array | ||
public function initializeArguments(): void | ||
{ | ||
$this->registerArgument('param', 'string', 'Name of the parameter key', true); | ||
} | ||
|
||
/** @var RenderingContext $renderingContext */ | ||
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): ?string | ||
{ | ||
$request = $renderingContext->getRequest(); | ||
$queryParams = $request->getQueryParams(); | ||
|
||
// Check if the argument param exists in the query parameters | ||
if (array_key_exists($arguments['param'], $queryParams)) { | ||
return $queryParams[$arguments['param']]; | ||
} | ||
|
||
return $request->getQueryParams(); | ||
|
||
// Return null if parameter does not exist | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters