‪TYPO3CMS  11.5
FormConditionFunctionsProvider.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Symfony\Component\ExpressionLanguage\ExpressionFunction;
21 use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface;
23 
27 class ‪FormConditionFunctionsProvider implements ExpressionFunctionProviderInterface
28 {
32  public function ‪getFunctions()
33  {
34  return [
35  $this->‪getFormValueFunction(),
37  ];
38  }
39 
45  protected function ‪getFormValueFunction(): ExpressionFunction
46  {
47  return new ExpressionFunction(
48  'getFormValue',
49  static function () {
50  // Not implemented, we only use the evaluator
51  },
52  static function ($arguments, $field) {
53  return $arguments['formValues'][$field] ?? null;
54  }
55  );
56  }
57 
61  protected function ‪getRootFormPropertyFunction(): ExpressionFunction
62  {
63  return new ExpressionFunction(
64  'getRootFormProperty',
65  static function () {
66  // Not implemented, we only use the evaluator
67  },
68  static function ($arguments, $property) {
69  $formDefinition = $arguments['formRuntime']->getFormDefinition();
70  try {
71  $value = ‪ObjectAccess::getPropertyPath($formDefinition, $property);
72  } catch (\‪Exception $exception) {
73  $value = null;
74  }
75  return $value;
76  }
77  );
78  }
79 }
‪TYPO3\CMS\Form\Domain\Condition\Functions\FormConditionFunctionsProvider\getFunctions
‪ExpressionFunction[] getFunctions()
Definition: FormConditionFunctionsProvider.php:32
‪TYPO3\CMS\Form\Domain\Condition\Functions
Definition: FormConditionFunctionsProvider.php:18
‪TYPO3\CMS\Extbase\Reflection\ObjectAccess
Definition: ObjectAccess.php:39
‪TYPO3\CMS\Form\Domain\Condition\Functions\FormConditionFunctionsProvider\getRootFormPropertyFunction
‪Symfony Component ExpressionLanguage ExpressionFunction getRootFormPropertyFunction()
Definition: FormConditionFunctionsProvider.php:61
‪TYPO3\CMS\Form\Domain\Condition\Functions\FormConditionFunctionsProvider\getFormValueFunction
‪Symfony Component ExpressionLanguage ExpressionFunction getFormValueFunction()
Definition: FormConditionFunctionsProvider.php:45
‪TYPO3\CMS\Form\Domain\Exception
Definition: Exception.php:25
‪TYPO3\CMS\Form\Domain\Condition\Functions\FormConditionFunctionsProvider
Definition: FormConditionFunctionsProvider.php:28
‪TYPO3\CMS\Extbase\Reflection\ObjectAccess\getPropertyPath
‪static mixed getPropertyPath($subject, string $propertyPath)
Definition: ObjectAccess.php:140