Zwischenstand
This commit is contained in:
51
Classes/Widgets/Provider/TopBookmarksDataProvider.php
Normal file
51
Classes/Widgets/Provider/TopBookmarksDataProvider.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
||||
namespace WapplerSystems\BookmarksLikesRatings\Widgets\Provider;
|
||||
|
||||
use TYPO3\CMS\Backend\Utility\BackendUtility;
|
||||
use WapplerSystems\BookmarksLikesRatings\Domain\Repository\BookmarkRepository;
|
||||
|
||||
class TopBookmarksDataProvider
|
||||
{
|
||||
|
||||
/** @var BookmarkRepository */
|
||||
protected $bookmarkRepository;
|
||||
|
||||
public function injectBookmarkRepository(BookmarkRepository $bookmarkRepository) {
|
||||
$this->bookmarkRepository = $bookmarkRepository;
|
||||
}
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public function getItems()
|
||||
{
|
||||
|
||||
$objs = $this->bookmarkRepository->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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user