[TYPO3-dev] Correct usage of translated records in CLI
Mika
m+typo3-dev at qxio.tk
Wed Jun 20 21:45:53 CEST 2018
Hello, its Mika again,
On 16.06.18 11:05, m+typo3-dev at qxio.tk wrote:
[...]
> Now my problem now is that I still get the record in the main laguage
> because DataMapper->mapSingleRow() (called via DataMapper->map()) has
> some kind of object cache and thus returns the object in the default
> language (because the uid is still the one of the record in the main
> language).
I feel quite lonely here. is this mailinglist still active?
I have two updates on my problem that I want to post here for
documentation purpose.
1) solution to the issue described above:
To avoid invoking the DataMapper as part of the query from
Typo3DbBackend, I used a raw query (argument for ->execute()) and get
back an array, that already went through language overlay etc. BUT: in
the array the '_LOCALIZED_UID' is still available. So I overwrite the
uid with the value from '_LOCALIZED_UID' and invoke the DataMapper
manually. Quite cumbersome and very hackish to overcome the Typo3
backend shortcomings...
2) alternative solution:
based on the solution above, I decided that I can do almost everything
on my own. So what I do now is
i) create an independend querybuilder for the according table:
> $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($tableName);
ii) select the record with the desired l10n_parent and sys_language_uid
> $query = $queryBuilder->select('*')
> ->from($tableName)
> ->where($queryBuilder->expr()->eq('sys_language_uid', $langId))
> ->andWhere($queryBuilder->expr()->eq('l10n_parent', $parentUid))
> ->execute();
iii) fetch all records into an array
> $rows = $query->fetchAll();
iv) invoke the DataMapper manually to get the object
> $dataMapper = $this->objectManager->get(DataMapper::class);
> $translated = $dataMapper->map($className, $rows);
I know it has nothing to do with the ModelRepository any more, but it
works quite fine for now...
that's all folks
best regards,
Mika
More information about the TYPO3-dev
mailing list