Zwischenstand
This commit is contained in:
@@ -5,34 +5,52 @@ declare(strict_types=1);
|
||||
|
||||
namespace WapplerSystems\BookmarksLikesRatings\Widgets\Provider;
|
||||
|
||||
use TYPO3\CMS\Core\Database\Connection;
|
||||
use TYPO3\CMS\Core\Database\ConnectionPool;
|
||||
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Dashboard\Widgets\ListDataProviderInterface;
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
use TYPO3\CMS\Core\Utility\DebugUtility;
|
||||
use WapplerSystems\BookmarksLikesRatings\Domain\Repository\LikeRepository;
|
||||
|
||||
class TopLikesDataProvider implements ListDataProviderInterface
|
||||
class TopLikesDataProvider
|
||||
{
|
||||
|
||||
/** @var LikeRepository */
|
||||
protected $likeRepository;
|
||||
|
||||
/**
|
||||
* @param \WapplerSystems\BookmarksLikesRatings\Domain\Repository\LikeRepository $bookmarkRepository
|
||||
*/
|
||||
public function injectLikeRepository(LikeRepository $likeRepository) {
|
||||
$this->likeRepository = $likeRepository;
|
||||
}
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public function getItems(): array
|
||||
public function getItems()
|
||||
{
|
||||
/** @var QueryBuilder $queryBuilder */
|
||||
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users');
|
||||
return $queryBuilder
|
||||
->count('*')
|
||||
->from('be_users')
|
||||
->where(
|
||||
$queryBuilder->expr()->eq(
|
||||
'admin',
|
||||
$queryBuilder->createNamedParameter(0, Connection::PARAM_INT)
|
||||
)
|
||||
)
|
||||
->execute();
|
||||
|
||||
|
||||
$objs = $this->likeRepository->getTop(10);
|
||||
|
||||
$items = [];
|
||||
|
||||
foreach ($objs as $obj) {
|
||||
$title = '';
|
||||
if ($obj['tablename'] === 'pages') {
|
||||
|
||||
$page = BackendUtility::getRecord('pages',$obj['object_uid'],'title');
|
||||
if ($page) {
|
||||
$title = $page['title'];
|
||||
}
|
||||
}
|
||||
$items[] = [
|
||||
'title' => $title,
|
||||
'number' => $obj['number']
|
||||
];
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@
|
||||
namespace WapplerSystems\BookmarksLikesRatings\Widgets;
|
||||
|
||||
use TYPO3\CMS\Dashboard\Widgets\ButtonProviderInterface;
|
||||
use TYPO3\CMS\Dashboard\Widgets\ListDataProviderInterface;
|
||||
use TYPO3\CMS\Dashboard\Widgets\WidgetConfigurationInterface;
|
||||
use TYPO3\CMS\Dashboard\Widgets\WidgetInterface;
|
||||
use TYPO3\CMS\Fluid\View\StandaloneView;
|
||||
@@ -53,9 +52,9 @@ class TopLikesWidget implements WidgetInterface
|
||||
|
||||
public function renderWidgetContent(): string
|
||||
{
|
||||
$this->view->setTemplate('Widget/ListWidget');
|
||||
$this->view->setTemplate('TopLikesWidget');
|
||||
$this->view->assignMultiple([
|
||||
'items' => $this->getItems(),
|
||||
'items' => $this->dataProvider->getItems(),
|
||||
'options' => $this->options,
|
||||
'button' => $this->buttonProvider,
|
||||
'configuration' => $this->configuration,
|
||||
@@ -63,8 +62,4 @@ class TopLikesWidget implements WidgetInterface
|
||||
return $this->view->render();
|
||||
}
|
||||
|
||||
protected function getItems(): array
|
||||
{
|
||||
return $this->dataProvider->getTopLikes();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user