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