Skip to content

Commit

Permalink
fix: make dashboard widgets compatible with TYPO3 v13
Browse files Browse the repository at this point in the history
  • Loading branch information
brotkrueml committed Aug 28, 2024
1 parent 319599e commit ca20c0e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
22 changes: 15 additions & 7 deletions Classes/Widgets/TransferReportWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,45 @@
namespace JobRouter\AddOn\Typo3Base\Widgets;

use JobRouter\AddOn\Typo3Base\Extension;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\View\BackendViewFactory;
use TYPO3\CMS\Dashboard\Widgets\AdditionalCssInterface;
use TYPO3\CMS\Dashboard\Widgets\ListDataProviderInterface;
use TYPO3\CMS\Dashboard\Widgets\RequestAwareWidgetInterface;
use TYPO3\CMS\Dashboard\Widgets\WidgetConfigurationInterface;
use TYPO3\CMS\Dashboard\Widgets\WidgetInterface;
use TYPO3\CMS\Fluid\View\StandaloneView;

/**
* @internal Only for usage in the TYPO3 JobRouter extensions!
*/
final class TransferReportWidget implements WidgetInterface, AdditionalCssInterface
final class TransferReportWidget implements WidgetInterface, AdditionalCssInterface, RequestAwareWidgetInterface
{
private ServerRequestInterface $request;

/**
* @param array<string, mixed> $options
*/
public function __construct(
private readonly WidgetConfigurationInterface $configuration,
private readonly ListDataProviderInterface $dataProvider,
private readonly StandaloneView $view,
private readonly BackendViewFactory $backendViewFactory,
private readonly array $options,
) {}

public function renderWidgetContent(): string
public function setRequest(ServerRequestInterface $request): void
{
$this->view->setTemplate('Widget/TransferReportWidget');
$this->request = $request;
}

$this->view->assignMultiple([
public function renderWidgetContent(): string
{
$view = $this->backendViewFactory->create($this->request);
$view->assignMultiple([
'configuration' => $this->configuration,
'items' => $this->dataProvider->getItems(),
]);

return $this->view->render();
return $view->render('Widget/TransferReportWidget');
}

/**
Expand Down
21 changes: 15 additions & 6 deletions Classes/Widgets/TransferStatusWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,44 @@

use JobRouter\AddOn\Typo3Base\Extension;
use JobRouter\AddOn\Typo3Base\Widgets\Provider\TransferStatusDataProviderInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\View\BackendViewFactory;
use TYPO3\CMS\Dashboard\Widgets\AdditionalCssInterface;
use TYPO3\CMS\Dashboard\Widgets\RequestAwareWidgetInterface;
use TYPO3\CMS\Dashboard\Widgets\WidgetConfigurationInterface;
use TYPO3\CMS\Dashboard\Widgets\WidgetInterface;
use TYPO3\CMS\Fluid\View\StandaloneView;

/**
* @internal Only for usage in the TYPO3 JobRouter extensions!
*/
class TransferStatusWidget implements WidgetInterface, AdditionalCssInterface
class TransferStatusWidget implements WidgetInterface, AdditionalCssInterface, RequestAwareWidgetInterface
{
private ServerRequestInterface $request;

/**
* @param array<string, mixed> $options
*/
public function __construct(
private readonly WidgetConfigurationInterface $configuration,
private readonly TransferStatusDataProviderInterface $dataProvider,
private readonly StandaloneView $view,
private readonly BackendViewFactory $backendViewFactory,
private readonly array $options = [],
) {}

public function setRequest(ServerRequestInterface $request): void
{
$this->request = $request;
}

public function renderWidgetContent(): string
{
$this->view->setTemplate('Widget/TransferStatusWidget');
$this->view->assignMultiple([
$view = $this->backendViewFactory->create($this->request);
$view->assignMultiple([
'status' => $this->dataProvider->getStatus(),
'configuration' => $this->configuration,
]);

return $this->view->render();
return $view->render('Widget/TransferStatusWidget');
}

/**
Expand Down
1 change: 1 addition & 0 deletions Configuration/page.tsconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
templates.typo3/cms-dashboard.1724765925 = jobrouter/typo3-base:Resources/Private

0 comments on commit ca20c0e

Please sign in to comment.