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