cache->get($this->cacheIdentifier); if ($classesConfigurationCache !== false) { return new ClassesConfiguration($classesConfigurationCache); } $classes = []; foreach ($this->packageManager->getActivePackages() as $activePackage) { $persistenceClassesFile = $activePackage->getPackagePath() . 'Configuration/Extbase/Persistence/Classes.php'; if (file_exists($persistenceClassesFile)) { $definedClasses = require $persistenceClassesFile; if (is_array($definedClasses)) { ArrayUtility::mergeRecursiveWithOverrule( $classes, $definedClasses, true, false ); } } } $classes = $this->inheritPropertiesFromParentClasses($classes); $this->cache->set($this->cacheIdentifier, $classes); return new ClassesConfiguration($classes); } /** * todo: this method is flawed, see https://forge.typo3.org/issues/87566 */ private function inheritPropertiesFromParentClasses(array $classes): array { foreach (array_keys($classes) as $className) { if (!isset($classes[$className]['properties'])) { $classes[$className]['properties'] = []; } /* * At first we need to clean the list of parent classes. * This methods is expected to be called for models that either inherit * AbstractEntity or AbstractValueObject, therefore we want to know all * parents of $className until one of these parents. */ $relevantParentClasses = []; $parentClasses = class_parents($className) ?: []; while (null !== $parentClass = array_shift($parentClasses)) { if (in_array($parentClass, [AbstractEntity::class, AbstractValueObject::class], true)) { break; } $relevantParentClasses[] = $parentClass; } /* * Once we found all relevant parent classes of $class, we can check their * property configuration and merge theirs with the current one. This is necessary * to get the property configuration of parent classes in the current one to not * miss data in the model later on. */ foreach ($relevantParentClasses as $currentClassName) { if (null === $properties = $classes[$currentClassName]['properties'] ?? null) { continue; } // Merge new properties over existing ones. $classes[$className]['properties'] = array_replace_recursive($properties, $classes[$className]['properties'] ?? []); } } return $classes; } }