[TASK] Use makeInstance in some hooks
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Form / Element / TextElement.php
index 9ab6a95..47d882a 100644 (file)
@@ -116,13 +116,20 @@ class TextElement extends AbstractFormElement {
                                if ($func === 'required') {
                                        $resultArray['requiredFields'][$table . '_' . $row['uid'] . '_' . $fieldName] = $parameterArray['itemFormElName'];
                                } else {
-                                       // Hint: There is a similar hook for "evaluateFieldValue" in DataHandler
-                                       $evalObj = GeneralUtility::getUserObj($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func] . ':&' . $func);
-                                       if (is_object($evalObj) && method_exists($evalObj, 'deevaluateFieldValue')) {
-                                               $_params = array(
-                                                       'value' => $parameterArray['itemFormElValue']
-                                               );
-                                               $parameterArray['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
+                                       // @todo: This is ugly: The code should find out on it's own whether a eval definition is a
+                                       // @todo: keyword like "date", or a class reference. The global registration could be dropped then
+                                       // Pair hook to the one in \TYPO3\CMS\Core\DataHandling\DataHandler::checkValue_input_Eval()
+                                       // There is a similar hook for "evaluateFieldValue" in DataHandler and InputElement
+                                       if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tce']['formevals'][$func])) {
+                                               if (class_exists($func)) {
+                                                       $evalObj = GeneralUtility::makeInstance($func);
+                                                       if (method_exists($evalObj, 'deevaluateFieldValue')) {
+                                                               $_params = array(
+                                                                       'value' => $parameterArray['itemFormElValue']
+                                                               );
+                                                               $parameterArray['itemFormElValue'] = $evalObj->deevaluateFieldValue($_params);
+                                                       }
+                                               }
                                        }
                                }
                        }