From 780d732d22669350fe4e4659fb743aaec4c0e0dc Mon Sep 17 00:00:00 2001 From: Thorben Nissen Date: Thu, 21 Mar 2019 17:25:11 +0100 Subject: [PATCH] [BUGFIX] Improve language handling * use extbase query as basis for generating alphabetic index (includes storage page(s), language settings) * allow glossary items to have `all` as language --- Classes/Domain/Repository/GlossaryRepository.php | 14 ++++++++------ Configuration/TCA/tx_a21glossary_main.php | 6 ++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Classes/Domain/Repository/GlossaryRepository.php b/Classes/Domain/Repository/GlossaryRepository.php index c71f081..7e26132 100644 --- a/Classes/Domain/Repository/GlossaryRepository.php +++ b/Classes/Domain/Repository/GlossaryRepository.php @@ -3,11 +3,9 @@ namespace SveWap\A21glossary\Domain\Repository; use SveWap\A21glossary\Domain\Model\Glossary; -use TYPO3\CMS\Core\Database\ConnectionPool; -use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Persistence\Exception\InvalidQueryException; -use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapFactory; use TYPO3\CMS\Extbase\Persistence\Generic\Query; +use TYPO3\CMS\Extbase\Persistence\Generic\Storage\Typo3DbQueryParser; use TYPO3\CMS\Extbase\Persistence\QueryInterface; use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; use TYPO3\CMS\Extbase\Persistence\Repository; @@ -25,9 +23,13 @@ public function findAllForIndex() { /** @var Query $query */ $query = $this->createQuery(); - $tableName = $this->objectManager->get(DataMapFactory::class)->buildDataMap($this->objectType)->getTableName(); - $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($tableName); - $queryBuilder->selectLiteral('substr(' . $queryBuilder->quoteIdentifier('short') . ', 1, 1) AS ' . $queryBuilder->quoteIdentifier('char'))->from($tableName)->groupBy('char'); + // Get the query parser via object manager to use dependency injection + $parser = $this->objectManager->get(Typo3DbQueryParser::class); + // Convert the extbase query to a query builder + $queryBuilder = $parser->convertQueryToDoctrineQueryBuilder($query); + // Add our select and group by + $queryBuilder->selectLiteral('substr(' . $queryBuilder->quoteIdentifier('short') . ', 1, 1) AS ' . $queryBuilder->quoteIdentifier('char')) + ->groupBy('char'); return $query->statement($queryBuilder)->execute(true); } diff --git a/Configuration/TCA/tx_a21glossary_main.php b/Configuration/TCA/tx_a21glossary_main.php index 9cb7d11..faec9ab 100644 --- a/Configuration/TCA/tx_a21glossary_main.php +++ b/Configuration/TCA/tx_a21glossary_main.php @@ -37,6 +37,12 @@ 'type' => 'select', 'renderType' => 'selectSingle', 'special' => 'languages', + 'items' => [ + [ + 'LLL:EXT:lang/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', + -1, + ], + ] ] ], 'l18n_parent' => [