‪TYPO3CMS  ‪main
CtaWidget.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 
36 {
40  private readonly array ‪$options;
41  private ServerRequestInterface ‪$request;
42 
43  public function ‪__construct(
44  private readonly ‪WidgetConfigurationInterface $configuration,
45  private readonly ‪BackendViewFactory $backendViewFactory,
46  private readonly ?‪ButtonProviderInterface $buttonProvider = null,
47  array ‪$options = [],
48  ) {
49  $this->options = array_merge(['text' => ''], ‪$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  'text' => $this->options['text'],
62  'options' => $this->options,
63  'button' => $this->buttonProvider,
64  'configuration' => $this->configuration,
65  ]);
66  return $view->render('Widget/CtaWidget');
67  }
68 
69  public function ‪getOptions(): array
70  {
71  return ‪$this->options;
72  }
73 }
‪TYPO3\CMS\Backend\View\BackendViewFactory
Definition: BackendViewFactory.php:35
‪TYPO3\CMS\Dashboard\Widgets\RequestAwareWidgetInterface
Definition: RequestAwareWidgetInterface.php:29
‪TYPO3\CMS\Dashboard\Widgets\WidgetInterface
Definition: WidgetInterface.php:26
‪TYPO3\CMS\Dashboard\Widgets\CtaWidget\renderWidgetContent
‪renderWidgetContent()
Definition: CtaWidget.php:57
‪TYPO3\CMS\Dashboard\Widgets\CtaWidget\$request
‪ServerRequestInterface $request
Definition: CtaWidget.php:41
‪TYPO3\CMS\Dashboard\Widgets\CtaWidget\getOptions
‪getOptions()
Definition: CtaWidget.php:69
‪TYPO3\CMS\Dashboard\Widgets\CtaWidget
Definition: CtaWidget.php:36
‪TYPO3\CMS\Dashboard\Widgets\CtaWidget\setRequest
‪setRequest(ServerRequestInterface $request)
Definition: CtaWidget.php:52
‪TYPO3\CMS\Dashboard\Widgets\CtaWidget\__construct
‪__construct(private readonly WidgetConfigurationInterface $configuration, private readonly BackendViewFactory $backendViewFactory, private readonly ?ButtonProviderInterface $buttonProvider=null, array $options=[],)
Definition: CtaWidget.php:43
‪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\CtaWidget\$options
‪readonly array $options
Definition: CtaWidget.php:40