2 namespace TYPO3\CMS\Extbase\Persistence\Generic\Mapper;
86 $this->dataMapCache = $this->cacheManager->getCache(
'extbase_datamapfactory_datamap');
99 $dataMap = $this->dataMapCache->get(str_replace(
'\\',
'%', $className));
100 if ($dataMap ===
false) {
101 $dataMap = $this->buildDataMapInternal($className);
102 $this->dataMapCache->set(str_replace(
'\\',
'%', $className), $dataMap);
116 protected function buildDataMapInternal($className)
118 if (!class_exists($className)) {
119 throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\InvalidClassException(
'Could not find class definition for name "' . $className .
'". This could be caused by a mis-spelling of the class name in the class definition.');
122 $subclasses = array();
124 $columnMapping = array();
125 $frameworkConfiguration = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
126 $classSettings = $frameworkConfiguration[
'persistence'][
'classes'][$className];
127 if ($classSettings !== null) {
128 if (isset($classSettings[
'subclasses']) && is_array($classSettings[
'subclasses'])) {
129 $subclasses = $this->
resolveSubclassesRecursive($frameworkConfiguration[
'persistence'][
'classes'], $classSettings[
'subclasses']);
131 if (isset($classSettings[
'mapping'][
'recordType']) && $classSettings[
'mapping'][
'recordType'] !==
'') {
132 $recordType = $classSettings[
'mapping'][
'recordType'];
134 if (isset($classSettings[
'mapping'][
'tableName']) && $classSettings[
'mapping'][
'tableName'] !==
'') {
135 $tableName = $classSettings[
'mapping'][
'tableName'];
137 $classHierarchy = array_merge(array($className), class_parents($className));
138 foreach ($classHierarchy as $currentClassName) {
139 if (in_array($currentClassName, array(\TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class, \TYPO3\CMS\Extbase\DomainObject\AbstractValueObject::class))) {
142 $currentClassSettings = $frameworkConfiguration[
'persistence'][
'classes'][$currentClassName];
143 if ($currentClassSettings !== null) {
144 if (isset($currentClassSettings[
'mapping'][
'columns']) && is_array($currentClassSettings[
'mapping'][
'columns'])) {
145 \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($columnMapping, $currentClassSettings[
'mapping'][
'columns'],
true,
false);
151 $dataMap = $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMap::class, $className, $tableName, $recordType, $subclasses);
155 \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($tcaColumnsDefinition, $columnMapping);
158 foreach ($tcaColumnsDefinition as $columnName => $columnDefinition) {
159 if (isset($columnDefinition[
'mapOnProperty'])) {
160 $propertyName = $columnDefinition[
'mapOnProperty'];
162 $propertyName = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToLowerCamelCase($columnName);
167 $propertyMetaData = $this->reflectionService->getClassSchema($className)->getProperty($propertyName);
168 $columnMap = $this->
setType($columnMap, $columnDefinition[
'config']);
169 $columnMap = $this->
setRelations($columnMap, $columnDefinition[
'config'], $propertyMetaData);
171 $dataMap->addColumnMap($columnMap);
184 $className = ltrim($className,
'\\');
185 if (strpos($className,
'\\') !==
false) {
186 $classNameParts = explode(
'\\', $className);
188 if (strpos($className,
'TYPO3\\CMS\\') === 0) {
189 $classPartsToSkip = 2;
191 $classPartsToSkip = 1;
193 $tableName =
'tx_' . strtolower(implode(
'_', array_slice($classNameParts, $classPartsToSkip)));
195 $tableName = strtolower($className);
210 $allSubclasses = array();
211 foreach ($subclasses as $subclass) {
212 $allSubclasses[] = $subclass;
213 if (isset($classesConfiguration[$subclass][
'subclasses']) && is_array($classesConfiguration[$subclass][
'subclasses'])) {
215 $allSubclasses = array_merge($allSubclasses, $childSubclasses);
218 return $allSubclasses;
229 return is_array(
$GLOBALS[
'TCA'][$tableName][
'ctrl']) ?
$GLOBALS[
'TCA'][$tableName][
'ctrl'] : null;
240 return is_array(
$GLOBALS[
'TCA'][$tableName][
'columns']) ?
$GLOBALS[
'TCA'][$tableName][
'columns'] : array();
250 $controlSection =
$GLOBALS[
'TCA'][$tableName][
'ctrl'];
251 $dataMap->setPageIdColumnName(
'pid');
252 if (isset($controlSection[
'tstamp'])) {
253 $dataMap->setModificationDateColumnName($controlSection[
'tstamp']);
255 if (isset($controlSection[
'crdate'])) {
256 $dataMap->setCreationDateColumnName($controlSection[
'crdate']);
258 if (isset($controlSection[
'cruser_id'])) {
259 $dataMap->setCreatorColumnName($controlSection[
'cruser_id']);
261 if (isset($controlSection[
'delete'])) {
262 $dataMap->setDeletedFlagColumnName($controlSection[
'delete']);
264 if (isset($controlSection[
'languageField'])) {
265 $dataMap->setLanguageIdColumnName($controlSection[
'languageField']);
267 if (isset($controlSection[
'transOrigPointerField'])) {
268 $dataMap->setTranslationOriginColumnName($controlSection[
'transOrigPointerField']);
270 if (isset($controlSection[
'transOrigDiffSourceField'])) {
271 $dataMap->setTranslationOriginDiffSourceName($controlSection[
'transOrigDiffSourceField']);
273 if (isset($controlSection[
'type'])) {
274 $dataMap->setRecordTypeColumnName($controlSection[
'type']);
276 if (isset($controlSection[
'rootLevel'])) {
277 $dataMap->setRootLevel($controlSection[
'rootLevel']);
279 if (isset($controlSection[
'is_static'])) {
280 $dataMap->setIsStatic($controlSection[
'is_static']);
282 if (isset($controlSection[
'enablecolumns'][
'disabled'])) {
283 $dataMap->setDisabledFlagColumnName($controlSection[
'enablecolumns'][
'disabled']);
285 if (isset($controlSection[
'enablecolumns'][
'starttime'])) {
286 $dataMap->setStartTimeColumnName($controlSection[
'enablecolumns'][
'starttime']);
288 if (isset($controlSection[
'enablecolumns'][
'endtime'])) {
289 $dataMap->setEndTimeColumnName($controlSection[
'enablecolumns'][
'endtime']);
291 if (isset($controlSection[
'enablecolumns'][
'fe_group'])) {
292 $dataMap->setFrontEndUserGroupColumnName($controlSection[
'enablecolumns'][
'fe_group']);
306 $tableColumnType = (isset($columnConfiguration[
'type'])) ? $columnConfiguration[
'type'] : null;
307 $columnMap->
setType(\TYPO3\CMS\Core\DataHandling\TableColumnType::cast($tableColumnType));
308 $tableColumnSubType = (isset($columnConfiguration[
'internal_type'])) ? $columnConfiguration[
'internal_type'] : null;
309 $columnMap->
setInternalType(\TYPO3\CMS\Core\DataHandling\TableColumnSubType::cast($tableColumnSubType));
325 if (isset($columnConfiguration)) {
326 if (isset($columnConfiguration[
'MM'])) {
328 }
elseif (isset($propertyMetaData[
'elementType'])) {
330 }
elseif (isset($propertyMetaData[
'type']) && strpbrk($propertyMetaData[
'type'],
'_\\') !==
false) {
332 }
elseif (isset($columnConfiguration[
'type']) && $columnConfiguration[
'type'] ===
'select' && isset($columnConfiguration[
'maxitems']) && $columnConfiguration[
'maxitems'] > 1) {
352 if (!empty($columnConfiguration[
'eval'])) {
353 $fieldEvaluations = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(
',', $columnConfiguration[
'eval'],
true);
354 $dateTimeEvaluations = array(
'date',
'datetime');
356 if (!empty(array_intersect($dateTimeEvaluations, $fieldEvaluations)) && !empty($columnConfiguration[
'dbType'])) {
380 if (is_array($columnConfiguration[
'foreign_match_fields'])) {
402 if (is_array($columnConfiguration[
'foreign_match_fields'])) {
419 if (isset($columnConfiguration[
'MM'])) {
424 if (is_array($columnConfiguration[
'MM_match_fields'])) {
427 if (is_array($columnConfiguration[
'MM_insert_fields'])) {
431 if (!empty($columnConfiguration[
'MM_opposite_field'])) {
441 throw new \TYPO3\CMS\Extbase\Persistence\Generic\Exception\UnsupportedRelationException(
'The given information to build a many-to-many-relation was not sufficient. Check your TCA definitions. mm-relations with IRRE must have at least a defined "MM" or "foreign_selector".', 1268817963);
459 return $this->objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\ColumnMap::class, $columnName, $propertyName);