‪TYPO3CMS  ‪main
FieldGeneratorResolver.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 
21 
28 {
36  protected ‪$fieldValueGenerators = [
37  // dbType = date / datetime have ['config']['default'] set, so match them before general ConfigDefault
38  FieldGenerator\TypeDatetimeFormatDateDbTypeDate::class,
39  FieldGenerator\TypeDatetimeDbTypeDatetime::class,
40 
41  // p/w generators are *before* 'default', so hashing kicks in, even if default is set.
42  FieldGenerator\TypePasswordHashedFalse::class,
43  FieldGenerator\TypePassword::class,
44 
45  // Use value from ['config']['default'] if given
46  FieldGenerator\ConfigDefault::class,
47 
48  // Specific type=input generator
49  FieldGenerator\TypeInputMax4Min4::class,
50  FieldGenerator\TypeInputMax4::class,
51  FieldGenerator\TypeInputEvalAlphanum::class,
52  FieldGenerator\TypeEmail::class,
53  FieldGenerator\TypeInputEvalIsIn::class,
54  FieldGenerator\TypeInputEvalMd5::class,
55  FieldGenerator\TypeInputEvalNum::class,
56  FieldGenerator\TypeInputEvalUpper::class,
57  FieldGenerator\TypeInputEvalYear::class,
58  FieldGenerator\TypeInputWizardSelect::class,
59  FieldGenerator\TypeInputDynamicTextWithRecordUid::class,
60  FieldGenerator\TypeInputForceL10nParent::class,
61  // General type=input generator
62  FieldGenerator\TypeInput::class,
63 
64  // Specific type=datetime generator
65  FieldGenerator\TypeDatetimeFormatDate::class,
66  FieldGenerator\TypeDatetimeRequiredFormatDate::class,
67  FieldGenerator\TypeDatetimeFormatTime::class,
68  FieldGenerator\TypeDatetimeFormatTimesec::class,
69  // General type=datetime generator
70  FieldGenerator\TypeDatetime::class,
71 
72  // General type=link generator
73  FieldGenerator\TypeLink::class,
74 
75  // General type=color generator
76  FieldGenerator\TypeColor::class,
77 
78  // Specific type=number generator
79  FieldGenerator\TypeNumberFormatDecimal::class,
80  // General type=number generator
81  FieldGenerator\TypeNumber::class,
82 
83  FieldGenerator\TypeTextDefaultExtrasRichtext::class,
84  FieldGenerator\TypeTextFormatDatetime::class,
85  FieldGenerator\TypeTextFormatCodeEditor::class,
86  FieldGenerator\TypeTextMax30::class,
87  FieldGenerator\TypeTextWizardSelect::class,
88  FieldGenerator\TypeTextWizardTable::class,
89  // General type=text generator
90  FieldGenerator\TypeText::class,
91 
92  // General type=check generator
93  FieldGenerator\TypeCheck::class,
94  // General type=radio generator
95  FieldGenerator\TypeRadio::class,
96 
97  // General type=none generator
98  FieldGenerator\TypeNoneFormatDateTime::class,
99  FieldGenerator\TypeNone::class,
100 
101  // General type=passthrough generator
102  FieldGenerator\TypePassthrough::class,
103  // General type=user generator
104  FieldGenerator\TypeUser::class,
105 
106  // type=group
107  FieldGenerator\TypeGroupFal::class,
108  FieldGenerator\TypeGroupAllowedBeUsersBeGroups::class,
109  FieldGenerator\TypeGroupAllowedBeUsers::class,
110  FieldGenerator\TypeGroupAllowedStaticdata::class,
111  FieldGenerator\TypeGroupAllowedPages::class,
112  FieldGenerator\TypeGroupAllowedSysFiles::class,
113 
114  // type=folder
115  FieldGenerator\TypeFolder::class,
116 
117  // type=select
118  FieldGenerator\TypeSelectRenderTypeSingleForeignTable::class,
119  FieldGenerator\TypeSelectRenderTypeSingleForeignTableGroupField::class,
120  FieldGenerator\TypeSelectRenderTypeSingleForeignTableForType::class,
121  FieldGenerator\TypeSelectRenderTypeSelectTree::class,
122  FieldGenerator\TypeSelectStaticData::class,
123  FieldGenerator\TypeSelect::class,
124 
125  // type=inline
126  FieldGenerator\TypeInlineFalSelectSingle12Foreign::class,
127  FieldGenerator\TypeInlineExpandsingle::class,
128  FieldGenerator\TypeInlineUsecombination::class,
129  FieldGenerator\TypeInlineUsecombinationGroup::class,
130 
131  // type=file
132  FieldGenerator\TypeFile::class,
133 
134  // type=imageManipulation
135  FieldGenerator\TypeImageManipulation::class,
136 
137  // General type=inline for simple 1:n parent child relations
138  FieldGenerator\TypeInline1n::class,
139 
140  // General type=flex generator
141  FieldGenerator\TypeFlex::class,
142  ];
143 
152  public function ‪resolve(array $data): ‪FieldGeneratorInterface
153  {
154  $generator = null;
155  foreach ($this->fieldValueGenerators as $fieldValueGenerator) {
156  $generator = GeneralUtility::makeInstance($fieldValueGenerator);
157  if (!$generator instanceof ‪FieldGeneratorInterface) {
158  throw new ‪Exception(
159  'Field value generator ' . $fieldValueGenerator . ' must implement FieldGeneratorInterface',
160  1457693564
161  );
162  }
163  if ($generator->match($data)) {
164  break;
165  }
166  $generator = null;
167  }
168  if (is_null($generator)) {
170  'No generator found',
171  1457873493
172  );
173  }
174  return $generator;
175  }
176 }
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGeneratorResolver
Definition: FieldGeneratorResolver.php:28
‪TYPO3\CMS\Styleguide\TcaDataGenerator\GeneratorNotFoundException
Definition: GeneratorNotFoundException.php:25
‪TYPO3\CMS\Styleguide\TcaDataGenerator
Definition: AbstractGenerator.php:18
‪TYPO3\CMS\Styleguide\TcaDataGenerator\Exception
Definition: Exception.php:25
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGeneratorResolver\$fieldValueGenerators
‪array $fieldValueGenerators
Definition: FieldGeneratorResolver.php:35
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGeneratorInterface
Definition: FieldGeneratorInterface.php:26
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Styleguide\TcaDataGenerator\FieldGeneratorResolver\resolve
‪FieldGeneratorInterface resolve(array $data)
Definition: FieldGeneratorResolver.php:151