‪TYPO3CMS  11.5
MultiValuePropertiesExtractor.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  [, $formElementType, $propertyCollectionName, $propertyCollectionIndex, $propertyCollectionEditorIndex] = $matches;
36 
37  if (
38  $value !== 'Inspector-PropertyGridEditor'
39  && $value !== 'Inspector-MultiSelectEditor'
40  && $value !== 'Inspector-ValidationErrorMessageEditor'
41  ) {
42  return;
43  }
44 
45  $propertyPath = implode(
46  '.',
47  [
48  'formElementsDefinition',
49  $formElementType,
50  'formEditor',
51  'propertyCollections',
52  $propertyCollectionName,
53  $propertyCollectionIndex,
54  'editors',
55  $propertyCollectionEditorIndex,
56  'propertyPath',
57  ]
58  );
59  $propertyValue = ‪ArrayUtility::getValueByPath($this->extractorDto->getPrototypeConfiguration(), $propertyPath, '.');
60 
61  $result = $this->extractorDto->getResult();
62 
63  if (
64  $value === 'Inspector-PropertyGridEditor'
65  || $value === 'Inspector-MultiSelectEditor'
66  ) {
67  $identifierPath = implode(
68  '.',
69  [
70  'formElementsDefinition',
71  $formElementType,
72  'formEditor',
73  'propertyCollections',
74  $propertyCollectionName,
75  $propertyCollectionIndex,
76  'identifier',
77  ]
78  );
79  $identifier = ‪ArrayUtility::getValueByPath($this->extractorDto->getPrototypeConfiguration(), $identifierPath, '.');
80 
81  $result['formElements'][$formElementType]['collections'][$propertyCollectionName][$identifier]['multiValueProperties'][] = $propertyValue;
82  if ($value === 'Inspector-PropertyGridEditor') {
83  $result['formElements'][$formElementType]['collections'][$propertyCollectionName][$identifier]['multiValueProperties'][] = 'defaultValue';
84  }
85  } else {
86  $result['formElements'][$formElementType]['multiValueProperties'][] = $propertyValue;
87  }
88 
89  $this->extractorDto->setResult($result);
90  }
91 }
‪TYPO3\CMS\Form\Domain\Configuration\FrameworkConfiguration\Extractors\PropertyCollectionElement\MultiValuePropertiesExtractor
Definition: MultiValuePropertiesExtractor.php:27
‪TYPO3\CMS\Form\Domain\Configuration\FrameworkConfiguration\Extractors\AbstractExtractor
Definition: AbstractExtractor.php:24
‪TYPO3\CMS\Core\Utility\ArrayUtility\getValueByPath
‪static mixed getValueByPath(array $array, $path, $delimiter='/')
Definition: ArrayUtility.php:180
‪TYPO3\CMS\Form\Domain\Configuration\FrameworkConfiguration\Extractors\PropertyCollectionElement
Definition: IsCreatablePropertyCollectionElementExtractor.php:18
‪TYPO3\CMS\Core\Utility\ArrayUtility
Definition: ArrayUtility.php:24
‪TYPO3\CMS\Form\Domain\Configuration\FrameworkConfiguration\Extractors\PropertyCollectionElement\MultiValuePropertiesExtractor\__invoke
‪__invoke(string $_, $value, array $matches)
Definition: MultiValuePropertiesExtractor.php:33