‪TYPO3CMS  11.5
PropertyPathsExtractor.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 
22 
27 {
33  public function ‪__invoke(string $_, $value, array $matches)
34  {
35  $formElementPropertyPaths = $this->‪getPropertyPaths($value, $matches);
36 
37  $result = $this->extractorDto->getResult();
38  $result = array_merge_recursive($result, ['formElements' => $formElementPropertyPaths]);
39  $this->extractorDto->setResult($result);
40  }
41 
47  protected function ‪getPropertyPaths(string $value, array $matches): array
48  {
49  $paths = [];
50  [, $formElementType, $formEditorIndex] = $matches;
51 
52  $paths[$formElementType]['propertyPaths'] = [];
53  $templateNamePath = implode(
54  '.',
55  [
56  'formElementsDefinition',
57  $formElementType,
58  'formEditor',
59  'editors',
60  $formEditorIndex,
61  'templateName',
62  ]
63  );
64  $templateName = ‪ArrayUtility::getValueByPath(
65  $this->extractorDto->getPrototypeConfiguration(),
66  $templateNamePath,
67  '.'
68  );
69 
70  // Special processing of "Inspector-GridColumnViewPortConfigurationEditor" inspector editors.
71  // Expand the property path which contains a "{@viewPortIdentifier}" placeholder
72  // to X property paths which contain all available placeholder replacements.
73  if ($templateName === 'Inspector-GridColumnViewPortConfigurationEditor') {
74  $viewPortsPath = implode(
75  '.',
76  [
77  'formElementsDefinition',
78  $formElementType,
79  'formEditor',
80  'editors',
81  $formEditorIndex,
82  'configurationOptions',
83  'viewPorts',
84  ]
85  );
86  $viewPorts = ‪ArrayUtility::getValueByPath($this->extractorDto->getPrototypeConfiguration(), $viewPortsPath, '.');
87  foreach ($viewPorts as $viewPort) {
88  $viewPortIdentifier = $viewPort['viewPortIdentifier'];
89  $propertyPath = str_replace('{@viewPortIdentifier}', $viewPortIdentifier, $value);
90  $paths[$formElementType]['propertyPaths'][] = $propertyPath;
91  }
92  } else {
93  $paths[$formElementType]['propertyPaths'][] = $value;
94  }
95  return $paths;
96  }
97 }
‪TYPO3\CMS\Form\Domain\Configuration\FrameworkConfiguration\Extractors\AbstractExtractor
Definition: AbstractExtractor.php:24
‪TYPO3\CMS\Form\Domain\Configuration\FrameworkConfiguration\Extractors\FormElement\PropertyPathsExtractor\getPropertyPaths
‪array getPropertyPaths(string $value, array $matches)
Definition: PropertyPathsExtractor.php:47
‪TYPO3\CMS\Form\Domain\Configuration\FrameworkConfiguration\Extractors\FormElement\PropertyPathsExtractor\__invoke
‪__invoke(string $_, $value, array $matches)
Definition: PropertyPathsExtractor.php:33
‪TYPO3\CMS\Core\Utility\ArrayUtility\getValueByPath
‪static mixed getValueByPath(array $array, $path, $delimiter='/')
Definition: ArrayUtility.php:180
‪TYPO3\CMS\Form\Domain\Configuration\FrameworkConfiguration\Extractors\FormElement
Definition: IsCreatableFormElementExtractor.php:18
‪TYPO3\CMS\Core\Utility\ArrayUtility
Definition: ArrayUtility.php:24
‪TYPO3\CMS\Form\Domain\Configuration\FrameworkConfiguration\Extractors\FormElement\PropertyPathsExtractor
Definition: PropertyPathsExtractor.php:27