`BeforeSearchFormIsShownEvent` is immutable
The BeforeSearchFormIsShownEvent is currently immutable. It has no setters or public variables whatsoever. This makes it pretty useless.
I wanted to inject some variables into the Search Form Template using this event, then found out that the event object can not be altered. An event should allow to actually alter or atleast add some variables when the event is fired.
ext:solr v12, TYPO3 v12, PHP v8.3.
Sometimes it is important to disallow the changes/side-effects, but allow the information retrieval. Which property do you want to override?
Edit: IMHO additionalFilters only is relevant for changes.
Edit: IMHO additionalFilters only is relevant for changes.
But this is immutable as well. I expected this event to provide the possibility to add (new, additional) template variables (which I then can use in my overridden Fluid template). I now created an extra ViewHelper to fetch it from inside the Search Form Template (which I see as spaghetti, beause Fluid Templates should not have any fetch logic, but get all stuff passed pre-calculated into).
Edit: IMHO additionalFilters only is relevant for changes.
But this is immutable as well. I expected this event to provide the possibility to add (new, additional) template variables (which I then can use in my overridden Fluid template). I now created an extra ViewHelper to fetch it from inside the Search Form Template (which I see as spaghetti, beause Fluid Templates should not have any fetch logic, but get all stuff passed pre-calculated into).
Please provide your suggestion as pull-request.
I have the same issue. I would like to provide the q parameter as it is not available in the search form. Before i could use the hook slot by using this code:
<?php
namespace Vendor\Extension\Slot;
class SearchFormSlot
{
public function addQueryStringToForm(array $values): array
{
$request = $GLOBALS['TYPO3_REQUEST'];
$queryParams = $request->getQueryParams();
$values['q'] = $queryParams['tx_solr']['q'] ?? null;
return [$values];
}
}
Now I'm not able to replace this code with the event as I can't set any values.
What would be really helpful would be the same functionality like here: #3915