1 | <?php |
||
22 | class PrefillMultiValueFieldViewHelper extends AbstractViewHelper |
||
23 | { |
||
24 | /** |
||
25 | * @var \TYPO3\CMS\Extbase\Property\PropertyMapper |
||
26 | */ |
||
27 | protected $propertyMapper = null; |
||
28 | |||
29 | /** |
||
30 | * @param PropertyMapper $propertyMapper |
||
31 | */ |
||
32 | public function injectPropertyMapper(\TYPO3\CMS\Extbase\Property\PropertyMapper $propertyMapper) |
||
36 | |||
37 | /** |
||
38 | * Initialize arguments |
||
39 | */ |
||
40 | public function initializeArguments() |
||
46 | |||
47 | /** |
||
48 | * Returns, if the given $currentValue is selected/checked for the given registration field |
||
49 | * If no originalRequest exist (form is not submitted), true is returned if the given $currentValue |
||
50 | * matches the default value of the field |
||
51 | * |
||
52 | * @return bool |
||
53 | */ |
||
54 | public function render() |
||
72 | |||
73 | /** |
||
74 | * Returns the submitted value for the given field uid |
||
75 | * |
||
76 | * @param array $submittedValues |
||
77 | * @param int $fieldUid |
||
78 | * @param string $currentValue |
||
79 | * @return bool |
||
80 | */ |
||
81 | protected function getFieldValueFromArguments($submittedValues, $fieldUid, $currentValue) |
||
94 | |||
95 | /** |
||
96 | * @param FieldValue $fieldValue |
||
97 | * @param string $currentValue |
||
98 | * @return bool |
||
99 | */ |
||
100 | protected function isGivenValueSelected($fieldValue, $currentValue) |
||
109 | |||
110 | /** |
||
111 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration\Field $registrationField |
||
112 | * @param string $currentValue |
||
113 | * @return bool |
||
114 | */ |
||
115 | protected function getFieldValueFromDefaultProperty($registrationField, $currentValue) |
||
121 | |||
122 | /** |
||
123 | * Shortcut for retrieving the request from the controller context |
||
124 | * |
||
125 | * @return \TYPO3\CMS\Extbase\Mvc\Request |
||
126 | */ |
||
127 | protected function getRequest() |
||
131 | } |
||
132 |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: