‪TYPO3CMS  ‪main
NumberWithIconWidget.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 
42 {
43  private ServerRequestInterface ‪$request;
44 
45  public function ‪__construct(
46  private readonly ‪WidgetConfigurationInterface $configuration,
47  private readonly ‪NumberWithIconDataProviderInterface $dataProvider,
48  private readonly ‪BackendViewFactory $backendViewFactory,
49  private readonly array $options = [],
50  ) {}
51 
52  public function ‪setRequest(ServerRequestInterface ‪$request): void
53  {
54  $this->request = ‪$request;
55  }
56 
57  public function ‪renderWidgetContent(): string
58  {
59  $view = $this->backendViewFactory->create($this->request);
60  $view->assignMultiple([
61  'icon' => $this->options['icon'] ?? '',
62  'title' => $this->options['title'] ?? '',
63  'subtitle' => $this->options['subtitle'] ?? '',
64  'number' => $this->dataProvider->getNumber(),
65  'options' => $this->options,
66  'configuration' => $this->configuration,
67  ]);
68  return $view->render('Widget/NumberWithIconWidget');
69  }
70 
71  public function ‪getOptions(): array
72  {
73  return $this->options;
74  }
75 }
‪TYPO3\CMS\Backend\View\BackendViewFactory
Definition: BackendViewFactory.php:35
‪TYPO3\CMS\Dashboard\Widgets\NumberWithIconDataProviderInterface
Definition: NumberWithIconDataProviderInterface.php:24
‪TYPO3\CMS\Dashboard\Widgets\RequestAwareWidgetInterface
Definition: RequestAwareWidgetInterface.php:29
‪TYPO3\CMS\Dashboard\Widgets\WidgetInterface
Definition: WidgetInterface.php:26
‪TYPO3\CMS\Dashboard\Widgets\NumberWithIconWidget\renderWidgetContent
‪renderWidgetContent()
Definition: NumberWithIconWidget.php:57
‪TYPO3\CMS\Dashboard\Widgets\NumberWithIconWidget\getOptions
‪getOptions()
Definition: NumberWithIconWidget.php:71
‪TYPO3\CMS\Dashboard\Widgets\NumberWithIconWidget\$request
‪ServerRequestInterface $request
Definition: NumberWithIconWidget.php:43
‪TYPO3\CMS\Dashboard\Widgets\NumberWithIconWidget\setRequest
‪setRequest(ServerRequestInterface $request)
Definition: NumberWithIconWidget.php:52
‪TYPO3\CMS\Dashboard\Widgets\NumberWithIconWidget
Definition: NumberWithIconWidget.php:42
‪TYPO3\CMS\Dashboard\Widgets\NumberWithIconWidget\__construct
‪__construct(private readonly WidgetConfigurationInterface $configuration, private readonly NumberWithIconDataProviderInterface $dataProvider, private readonly BackendViewFactory $backendViewFactory, private readonly array $options=[],)
Definition: NumberWithIconWidget.php:45
‪TYPO3\CMS\Dashboard\Widgets
Definition: AdditionalCssInterface.php:18
‪TYPO3\CMS\Dashboard\Widgets\WidgetConfigurationInterface
Definition: WidgetConfigurationInterface.php:26