|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Extension "sf_event_mgt" for TYPO3 CMS. |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please read the |
|
9
|
|
|
* LICENSE.txt file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace DERHANSEN\SfEventMgt\ViewHelpers; |
|
13
|
|
|
|
|
14
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
|
15
|
|
|
use TYPO3\CMS\Extbase\Mvc\Request; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
class PrefillViewHelper extends AbstractPrefillViewHelper |
|
18
|
|
|
{ |
|
19
|
|
|
public function initializeArguments(): void |
|
20
|
|
|
{ |
|
21
|
|
|
parent::initializeArguments(); |
|
22
|
|
|
$this->registerArgument('fieldname', 'string', 'Fieldname', true); |
|
23
|
|
|
$this->registerArgument('prefillSettings', 'array', 'PrefillSettings', false, []); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* If the current field is available in POST data of the current request, return the value, otherwise |
|
28
|
|
|
* a property from fe_user (if logged in and if the given field is configured to be prefilled) is returned. |
|
29
|
|
|
*/ |
|
30
|
|
|
public function render(): string |
|
31
|
|
|
{ |
|
32
|
|
|
$fieldname = $this->arguments['fieldname']; |
|
33
|
|
|
$prefillSettings = $this->arguments['prefillSettings']; |
|
34
|
|
|
|
|
35
|
|
|
/** @var Request $request */ |
|
36
|
|
|
$request = $this->renderingContext->getAttribute(ServerRequestInterface::class); |
|
37
|
|
|
$registrationData = $request->getParsedBody()[$this->getPluginNamespace($request)] ?? []; |
|
38
|
|
|
if (isset($registrationData['registration'][$fieldname])) { |
|
39
|
|
|
return $registrationData['registration'][$fieldname]; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$frontendUser = $request->getAttribute('frontend.user'); |
|
43
|
|
|
if (!$frontendUser->user || empty($prefillSettings) || |
|
44
|
|
|
!array_key_exists($fieldname, $prefillSettings) |
|
45
|
|
|
) { |
|
46
|
|
|
return ''; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
return (string)($frontendUser->user[$prefillSettings[$fieldname]] ?? ''); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths