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 @@ ...@@ -2,9 +2,9 @@
namespace T3o\T3orgLayout\TCA; namespace T3o\T3orgLayout\TCA;
use Doctrine\DBAL\Query\QueryBuilder;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository;
use TYPO3\CMS\Extbase\Object\ObjectManager;
class TcaProcFunc class TcaProcFunc
{ {
...@@ -14,29 +14,28 @@ class TcaProcFunc ...@@ -14,29 +14,28 @@ class TcaProcFunc
*/ */
public function feUserItems($config): array public function feUserItems($config): array
{ {
$itemList = []; /** @var QueryBuilder $queryBuilder */
$objectManager = GeneralUtility::makeInstance(ObjectManager::class); $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('fe_users');
$users = $queryBuilder
$querySettings = $objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings::class); ->select('*')
$querySettings->setRespectStoragePage(FALSE); ->from('fe_users')
->orderBy('name')
$orderings = array('name' => \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING); ->execute()
->fetchAll();
$userRepository = $objectManager->get(FrontendUserRepository::class);
$userRepository->setDefaultQuerySettings($querySettings); $itemList = array();
$userRepository->setDefaultOrderings($orderings);
if (\is_array($users)) {
$users = $userRepository->findAll(); foreach ($users as $user) {
foreach ($users as $user) { if ($user['name']) {
/** @var $user \TYPO3\CMS\Extbase\Domain\Model\FrontendUser */ $label = $user['name'];
if ($user->getName()) {
$label = $user->getName();
} else { } else {
$label = $user->getUid(); $label = $user['uid'];
} }
$itemList[] = [$label, $user->getUsername()]; $itemList[] = [$label, $user['username']];
}
$config['items'] = $itemList;
} }
$config['items'] = $itemList;
return $config; 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