71 lines
1.8 KiB
PHP
71 lines
1.8 KiB
PHP
<?php
|
|
|
|
|
|
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;
|
|
use WapplerSystems\BookmarksLikesRatings\Widgets\Provider\TopLikesDataProvider;
|
|
|
|
class TopLikesWidget implements WidgetInterface
|
|
{
|
|
/**
|
|
* @var WidgetConfigurationInterface
|
|
*/
|
|
private $configuration;
|
|
|
|
/**
|
|
* @var StandaloneView
|
|
*/
|
|
private $view;
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
private $options;
|
|
/**
|
|
* @var ButtonProviderInterface|null
|
|
*/
|
|
private $buttonProvider;
|
|
|
|
/**
|
|
* @var TopLikesDataProvider
|
|
*/
|
|
private $dataProvider;
|
|
|
|
public function __construct(
|
|
WidgetConfigurationInterface $configuration,
|
|
TopLikesDataProvider $dataProvider,
|
|
StandaloneView $view,
|
|
$buttonProvider = null,
|
|
array $options = []
|
|
)
|
|
{
|
|
$this->configuration = $configuration;
|
|
$this->view = $view;
|
|
$this->options = $options;
|
|
$this->buttonProvider = $buttonProvider;
|
|
$this->dataProvider = $dataProvider;
|
|
}
|
|
|
|
public function renderWidgetContent(): string
|
|
{
|
|
$this->view->setTemplate('Widget/ListWidget');
|
|
$this->view->assignMultiple([
|
|
'items' => $this->getItems(),
|
|
'options' => $this->options,
|
|
'button' => $this->buttonProvider,
|
|
'configuration' => $this->configuration,
|
|
]);
|
|
return $this->view->render();
|
|
}
|
|
|
|
protected function getItems(): array
|
|
{
|
|
return $this->dataProvider->getTopLikes();
|
|
}
|
|
}
|