Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Make DmWidget dashboard compatible with TYPO3 v12 #506

Open
wants to merge 1 commit into
base: 12.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 23 additions & 37 deletions Classes/Widgets/DmWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,59 +6,45 @@


use DirectMailTeam\DirectMail\Widgets\Provider\DmProvider;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\View\BackendViewFactory;
use TYPO3\CMS\Core\Utility\GeneralUtility;
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 DmWidget implements WidgetInterface
class DmWidget implements WidgetInterface, RequestAwareWidgetInterface
{
/**
* @var WidgetConfigurationInterface
*/
private $configuration;

/**
* @var StandaloneView
*/
private $view;

/**
* @var DmProvider
*/
private $dataProvider;

/**
* @var array
*/
private $options;

private ServerRequestInterface $request;
public function __construct(
WidgetConfigurationInterface $configuration,
DmProvider $dataProvider,
StandaloneView $view,
array $options = []
protected readonly WidgetConfigurationInterface $configuration,
protected readonly DmProvider $dataProvider,
protected readonly BackendViewFactory $backendViewFactory,
protected array $options = []
) {
$this->configuration = $configuration;
$this->dataProvider = $dataProvider;
$this->view = $view;
$this->options = $options;
}

public function renderWidgetContent(): string
{
$this->view->setTemplate('DmWidget');
$this->view->assignMultiple([
'items' => $this->dataProvider->getDmPages(),
'options' => $this->options,
'configuration' => $this->configuration,
]);
return $this->view->render();
return $this->backendViewFactory
->create($this->request, ['typo3/cms-dashboard', 'directmailteam/direct-mail'])
->assignMultiple([
'items' => $this->dataProvider->getDmPages(),
'configuration' => $this->configuration,
'options' => $this->options,
])
->render('Dashboard/Widgets/DmWidget');
}

public function getOptions(): array
{
return [];
return $this->options;
}

public function setRequest(ServerRequestInterface $request): void
{
$this->request = $request;
}
}
1 change: 0 additions & 1 deletion Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ services:
dashboard.widget.dm:
class: 'DirectMailTeam\DirectMail\Widgets\DmWidget'
arguments:
$view: '@dashboard.views.widget'
$dataProvider: '@dashboard.provider.dm'
tags:
- name: dashboard.widget
Expand Down