[TASK] Streamline expressionLanguage usage in core
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Classes / Domain / Condition / Functions / FormConditionFunctionsProvider.php
1 <?php
2 declare(strict_types = 1);
3
4 namespace TYPO3\CMS\Form\Domain\Condition\Functions;
5
6 use Symfony\Component\ExpressionLanguage\ExpressionFunction;
7 use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
8
9 class FormConditionFunctionsProvider implements ExpressionFunctionProviderInterface
10 {
11
12 /**
13 * @return ExpressionFunction[] An array of Function instances
14 */
15 public function getFunctions()
16 {
17 return [
18 $this->getFormValueFunction()
19 ];
20 }
21
22 /**
23 * Shortcut function to access field values
24 *
25 * @return \Symfony\Component\ExpressionLanguage\ExpressionFunction
26 */
27 protected function getFormValueFunction(): ExpressionFunction
28 {
29 return new ExpressionFunction(
30 'getFormValue',
31 function ($str) {
32 // Not implemented, we only use the evaluator
33 },
34 function ($arguments, $field) {
35 return $arguments['formValues'][$field] ?? null;
36 }
37 );
38 }
39 }