diff --git a/Classes/Widget/CommentsWidget.php b/Classes/Widget/CommentsWidget.php index 62462c3..9dc8639 100644 --- a/Classes/Widget/CommentsWidget.php +++ b/Classes/Widget/CommentsWidget.php @@ -12,39 +12,50 @@ * of the License, or any later version. */ -use B13\Annotate\Domain\Repository\CommentRepository; use Doctrine\DBAL\ParameterType; +use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Database\ConnectionPool; -use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Core\View\ViewFactoryData; +use TYPO3\CMS\Core\View\ViewFactoryInterface; +use TYPO3\CMS\Dashboard\Widgets\RequestAwareWidgetInterface; use TYPO3\CMS\Dashboard\Widgets\WidgetConfigurationInterface; use TYPO3\CMS\Dashboard\Widgets\WidgetInterface; -use TYPO3\CMS\Fluid\View\StandaloneView; -class CommentsWidget implements WidgetInterface +class CommentsWidget implements WidgetInterface, RequestAwareWidgetInterface { + private ServerRequestInterface $request; + public function __construct( - protected WidgetConfigurationInterface $configuration, - protected StandaloneView $view, - protected CommentRepository $commentRepository, - protected ConnectionPool $connectionPool + private readonly WidgetConfigurationInterface $configuration, + private readonly ViewFactoryInterface $viewFactory, + private readonly ConnectionPool $connectionPool ) {} + public function setRequest(ServerRequestInterface $request): void + { + $this->request = $request; + } + public function renderWidgetContent(): string { - $this->view->setTemplatePathAndFilename('EXT:annotate/Resources/Private/Templates/Widget/Comments.html'); - $this->view->assignMultiple([ + $view = $this->viewFactory->create(new ViewFactoryData( + layoutRootPaths: ['EXT:dashboard/Resources/Private/Layouts/'], + templateRootPaths: ['EXT:annotate/Resources/Private/Templates'], + request: $this->request + )); + $view->assignMultiple([ 'pages' => $this->getPagesWithComments(), 'configuration' => $this->configuration, ]); - return $this->view->render(); + return $view->render('Widget/Comments'); } protected function getPagesWithComments(): array { $queryBuilder = $this->connectionPool->getQueryBuilderForTable('pages'); return $queryBuilder - ->select('pages.uid', 'pages.title') - ->add('select', 'COUNT(sys_comment.uid) AS commentCount', true) + ->selectLiteral('COUNT(sys_comment.uid) AS commentCount') + ->addSelect('pages.uid', 'pages.title') ->from('pages') ->innerJoin( 'pages', diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index d14e1db..9480de8 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -9,8 +9,6 @@ services: dashboard.widget.annotate: class: B13\AnnotateWidget\Widget\CommentsWidget - arguments: - $view: '@dashboard.views.widget' tags: - name: dashboard.widget identifier: annotate diff --git a/composer.json b/composer.json index 59c9dd5..4328144 100644 --- a/composer.json +++ b/composer.json @@ -3,9 +3,8 @@ "type": "typo3-cms-extension", "description": "Extension providing a TYPO3 Dashboard widget for b13/annotate", "require": { - "php": "^8", - "typo3/cms-core": "^11.5 || ^12.4", - "typo3/cms-dashboard": "^11.5 || ^12.4", + "typo3/cms-core": "^13.4 || ^14.1 || ^14.2.x-dev", + "typo3/cms-dashboard": "^13.4 || ^14.1 || ^14.2.x-dev", "b13/annotate": "*" }, "extra": {