$className * @phpstan-return QueryInterface */ public function create($className): QueryInterface { $query = GeneralUtility::makeInstance(QueryInterface::class); $query->setType($className); $querySettings = GeneralUtility::makeInstance(QuerySettingsInterface::class); $dataMap = $this->dataMapFactory->buildDataMap($className); if ($dataMap->rootLevel) { $querySettings->setRespectStoragePage(false); } $storagePid = '0'; try { $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); $storagePid = (string)($frameworkConfiguration['persistence']['storagePid'] ?? '0'); } catch (NoServerRequestGivenException) { // Fallback to storagePid 0 if ConfigurationManager has not been initialized with a Request. This // is a measure to specifically allow running the extbase persistence layer without a Request, which // may be useful in some CLI scenarios (and can be convenient in tests) when no other code branches // of extbase that have a hard dependency to the Request (e.g. controllers / view) are used. } $querySettings->setStoragePageIds(GeneralUtility::intExplode(',', $storagePid)); $query->setQuerySettings($querySettings); return $query; } }