‪TYPO3CMS  ‪main
ListWidget.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\ServerRequestInterface;
22 
35 {
36  private ServerRequestInterface ‪$request;
37 
38  public function ‪__construct(
39  private readonly ‪WidgetConfigurationInterface $configuration,
40  private readonly ‪ListDataProviderInterface $dataProvider,
41  private readonly ‪BackendViewFactory $backendViewFactory,
42  private readonly ?‪ButtonProviderInterface $buttonProvider = null,
43  private readonly array $options = [],
44  ) {}
45 
46  public function ‪setRequest(ServerRequestInterface ‪$request): void
47  {
48  $this->request = ‪$request;
49  }
50 
51  public function ‪renderWidgetContent(): string
52  {
53  $view = $this->backendViewFactory->create($this->request);
54  $view->assignMultiple([
55  'items' => $this->‪getItems(),
56  'options' => $this->options,
57  'button' => $this->buttonProvider,
58  'configuration' => $this->configuration,
59  ]);
60  return $view->render('Widget/ListWidget');
61  }
62 
63  protected function ‪getItems(): array
64  {
65  return $this->dataProvider->getItems();
66  }
67 
68  public function ‪getOptions(): array
69  {
70  return $this->options;
71  }
72 }
‪TYPO3\CMS\Backend\View\BackendViewFactory
Definition: BackendViewFactory.php:35
‪TYPO3\CMS\Dashboard\Widgets\ListWidget\renderWidgetContent
‪renderWidgetContent()
Definition: ListWidget.php:51
‪TYPO3\CMS\Dashboard\Widgets\RequestAwareWidgetInterface
Definition: RequestAwareWidgetInterface.php:29
‪TYPO3\CMS\Dashboard\Widgets\WidgetInterface
Definition: WidgetInterface.php:26
‪TYPO3\CMS\Dashboard\Widgets\ListWidget\$request
‪ServerRequestInterface $request
Definition: ListWidget.php:36
‪TYPO3\CMS\Dashboard\Widgets\ListDataProviderInterface
Definition: ListDataProviderInterface.php:24
‪TYPO3\CMS\Dashboard\Widgets\ListWidget\setRequest
‪setRequest(ServerRequestInterface $request)
Definition: ListWidget.php:46
‪TYPO3\CMS\Dashboard\Widgets\ListWidget\getOptions
‪getOptions()
Definition: ListWidget.php:68
‪TYPO3\CMS\Dashboard\Widgets\ListWidget
Definition: ListWidget.php:35
‪TYPO3\CMS\Dashboard\Widgets\ListWidget\getItems
‪getItems()
Definition: ListWidget.php:63
‪TYPO3\CMS\Dashboard\Widgets
Definition: AdditionalCssInterface.php:18
‪TYPO3\CMS\Dashboard\Widgets\ButtonProviderInterface
Definition: ButtonProviderInterface.php:24
‪TYPO3\CMS\Dashboard\Widgets\WidgetConfigurationInterface
Definition: WidgetConfigurationInterface.php:26
‪TYPO3\CMS\Dashboard\Widgets\ListWidget\__construct
‪__construct(private readonly WidgetConfigurationInterface $configuration, private readonly ListDataProviderInterface $dataProvider, private readonly BackendViewFactory $backendViewFactory, private readonly ?ButtonProviderInterface $buttonProvider=null, private readonly array $options=[],)
Definition: ListWidget.php:38