Commit 232ad101 authored by Stefan Busemann's avatar Stefan Busemann
Browse files

[TASK] Refactor query without extbase

use doctrine for query
parent 26551b0e
Pipeline #4824 passed with stages
in 3 minutes
......@@ -2,9 +2,9 @@
namespace T3o\T3orgLayout\TCA;
use Doctrine\DBAL\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository;
use TYPO3\CMS\Extbase\Object\ObjectManager;
class TcaProcFunc
{
......@@ -14,29 +14,28 @@ class TcaProcFunc
*/
public function feUserItems($config): array
{
$itemList = [];
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$querySettings = $objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings::class);
$querySettings->setRespectStoragePage(FALSE);
$orderings = array('name' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING);
$userRepository = $objectManager->get(FrontendUserRepository::class);
$userRepository->setDefaultQuerySettings($querySettings);
$userRepository->setDefaultOrderings($orderings);
$users = $userRepository->findAll();
foreach ($users as $user) {
/** @var $user \TYPO3\CMS\Extbase\Domain\Model\FrontendUser */
if ($user->getName()) {
$label = $user->getName();
/** @var QueryBuilder $queryBuilder */
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('fe_users');
$users = $queryBuilder
->select('*')
->from('fe_users')
->orderBy('name')
->execute()
->fetchAll();
$itemList = array();
if (\is_array($users)) {
foreach ($users as $user) {
if ($user['name']) {
$label = $user['name'];
} else {
$label = $user->getUid();
$label = $user['uid'];
}
$itemList[] = [$label, $user->getUsername()];
$itemList[] = [$label, $user['username']];
}
$config['items'] = $itemList;
}
$config['items'] = $itemList;
return $config;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment