Feature #104763
Updated by Jannis Bell 3 months ago
My Company uses a self-developed extension for some forms.
We use the Request Argument Objects extensively.
<pre><code class="php">
class InquiryController extends ActionController {
public function processAction(\MyExt\Domain\Model\Demand\Inquiry $inquiry = NULL): ResponseInterface
</code></pre>
And we have to overwrite and adapt the forms constantly for our customers.
Specifically the Validators are hard to change.
The Request Argument Objects/Classes are not overwriteable with XClass.
Is there another way, I dont know about, how we can overwrite the Classes?
OR
can you add this to the core:
https://github.com/TYPO3/typo3/blob/main/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php#L238
<pre><code class="php">
protected function initializeActionMethodArguments(): void
{
$methodParameters = $this->reflectionService
->getClassSchema(static::class)
->getMethod($this->actionMethodName)->getParameters();
foreach ($methodParameters as $parameterName => $parameter) {
$dataType = null;
if ($parameter->getType() !== null) {
$dataType = $parameter->getType();
/** This is the new part:*/
// this can overwrite the Datatype aka Classname to match the given XClass counterpart
if (array_key_exists($dataType, $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'])) {
$dataType = $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][$dataType]['className'];
}
/** end of the new part */
} elseif ($parameter->isArray()) {
$dataType = 'array';
}
if ($dataType === null) {
throw new InvalidArgumentTypeException('The argument type for parameter $' . $parameterName . ' of method ' . static::class . '->' . $this->actionMethodName . '() could not be detected.', 1253175643);
}
$defaultValue = $parameter->hasDefaultValue() ? $parameter->getDefaultValue() : null;
$this->arguments->addNewArgument($parameterName, $dataType, !$parameter->isOptional(), $defaultValue);
}
}
</code></pre>
I am not sure about the code standards in the core:
Im not sure if you rather use isset() than array_key_exists()
Or if the XClass has no 'classname', if the core should crash or warn or cover this
Also im sry if this is very gibberish and poorly explained