logger = $logManager->getLogger(self::class); } public function getIdentifier(): string { return 'gridelementsToContainer'; } public function getTitle(): string { return 'Migrate gridelements to container'; } public function getDescription(): string { return 'Migrates content elements that are type gridelements 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 { return (bool)$this->getPreparedQueryBuilder()->count('uid')->executeQuery()->fetchOne(); } 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( $queryBuilder->expr()->eq('CType', $queryBuilder->createNamedParameter('gridelements_pi1')) ); return $queryBuilder; } protected function getConnectionPool(): ConnectionPool { return GeneralUtility::makeInstance(ConnectionPool::class); } }