Commit 85bf1145 authored by Thomas Löffler's avatar Thomas Löffler
Browse files

Merge branch '322-extend-news-model-for-author_fe_user' into 'develop'

Resolve "Extend news model for author_fe_user"

Closes #322

See merge request t3o/typo3.org!205
parents ec67eb77 401f8b7a
Pipeline #4873 passed with stages
in 6 minutes and 48 seconds
<?php
namespace T3o\T3orgLayout\Domain\Model;
/*
* This file is part of the TYPO3 project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License, either version 3
* of the License, or (at your option) any later version.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* Class News
*
* @package T3o\T3orgLayout\Domain\Model
*/
class News extends \GeorgRinger\News\Domain\Model\News
{
/**
* @var string
*
*/
protected $authorFeUser;
/**
* @param string $authorFeUser
*/
public function setAuthorFeUser(string $authorFeUser)
{
$this->authorFeUser = $authorFeUser;
}
/**
* @return \TYPO3\CMS\Extbase\Domain\Model\FrontendUser|null
*/
public function getAuthorFeUser()
{
if (!$this->authorFeUser) {
return null;
}
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
$querySettings = $objectManager->get(\TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings::class);
$querySettings->setRespectStoragePage(false);
$userRepository = $objectManager->get(\TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository::class);
$userRepository->setDefaultQuerySettings($querySettings);
return $userRepository->findOneByUsername($this->authorFeUser);
}
}
......@@ -8,11 +8,8 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
class TcaProcFunc
{
/**
* @param array $config
* @return array
*/
public function feUserItems($config): array
public function feUserItems(array $config): array
{
/** @var QueryBuilder $queryBuilder */
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('fe_users');
......@@ -23,19 +20,16 @@ class TcaProcFunc
->execute()
->fetchAll();
$itemList = array();
if (\is_array($users)) {
foreach ($users as $user) {
if ($user['name']) {
$label = $user['name'];
} else {
$label = $user['uid'];
}
$itemList[] = [$label, $user['username']];
$itemList = [];
foreach ($users as $user) {
if ($user['name']) {
$label = $user['name'];
} else {
$label = $user['uid'];
}
$config['items'] = $itemList;
$itemList[] = [$label, $user['username']];
}
$config['items'] = $itemList;
return $config;
}
......
......@@ -5,10 +5,11 @@ $GLOBALS['TCA']['tx_news_domain_model_news']['columns']['author_fe_user'] = [
'label' => 'Select fe user',
'config' => [
'type' => 'select',
'minitems' => 0,
'maxitems' => 1,
'renderType' => 'selectMultipleSideBySide',
'enableMultiSelectFilterTextfield' => true,
'itemsProcFunc' => 'T3o\\T3orgLayout\\TCA\\TcaProcFunc->feUserItems',
'maxitems' => 1
'itemsProcFunc' => \T3o\T3orgLayout\TCA\TcaProcFunc::class . '->feUserItems',
]
];
......
......@@ -6,3 +6,5 @@
// url index.php?eID=SolrSuggest&term=sdfsdfsdf
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['SolrSuggest'] = \T3o\T3orgLayout\Controller\SolrInstantSearchController::class . '::suggest';
$GLOBALS['TYPO3_CONF_VARS']['EXT']['news']['classes']['Domain/Model/News'][] = 't3org_layout';
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