logger = $logManager->getLogger(self::class); } public function getTitle(): string { return 'Migrate parent/child to container'; } public function getDescription(): string { return 'Migrates content elements that are type parent/child to corresponding container elements'; } public function getPrerequisites(): array { return [ DatabaseUpdatedPrerequisite::class ]; } public function updateNecessary(): bool { return $this->hasRecordsToUpdate(); } public function executeUpdate(): bool { $updateSuccessful = true; try { $this->service->migrate(); } catch (\Exception $exception) { $this->logger->log(LogLevel::ERROR, $exception->getMessage()); $updateSuccessful = false; } return $updateSuccessful; } protected function hasRecordsToUpdate(): bool { $queryBuilder = $this->getPreparedQueryBuilder(); $tableColumns = $queryBuilder ->getConnection() ->createSchemaManager() ->listTableColumns(self::TABLE_NAME); return isset($tableColumns['parent']) && $queryBuilder ->count('uid') ->executeQuery() ->fetchOne() > 0; } protected function getPreparedQueryBuilder(): QueryBuilder { $queryBuilder = $this->getConnectionPool()->getQueryBuilderForTable(self::TABLE_NAME); $queryBuilder->getRestrictions() ->removeByType(HiddenRestriction::class) ->removeByType(StartTimeRestriction::class) ->removeByType(EndTimeRestriction::class); $queryBuilder ->from(self::TABLE_NAME) ->where( // check if there are still records that have parent instead of tx_container_parent $queryBuilder->expr()->gt('parent', 0) ); return $queryBuilder; } protected function getConnectionPool(): ConnectionPool { return GeneralUtility::makeInstance(ConnectionPool::class); } }