‪TYPO3CMS  11.5
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 
21 
34 class CtaWidget implements WidgetInterface
35 {
39  private $configuration;
40 
44  private $view;
45 
49  private $options;
50 
54  private $buttonProvider;
55 
56  public function __construct(
57  WidgetConfigurationInterface $configuration,
58  StandaloneView $view,
59  $buttonProvider = null,
60  array $options = []
61  ) {
62  $this->configuration = $configuration;
63  $this->view = $view;
64  $this->options = array_merge(['text' => ''], $options);
65  $this->buttonProvider = $buttonProvider;
66  }
67 
68  public function renderWidgetContent(): string
69  {
70  $this->view->setTemplate('Widget/CtaWidget');
71  $this->view->assignMultiple([
72  'text' => $this->options['text'],
73  'options' => $this->options,
74  'button' => $this->buttonProvider,
75  'configuration' => $this->configuration,
76  ]);
77  return $this->view->render();
78  }
79 
83  public function getOptions(): array
84  {
85  return $this->options;
86  }
87 }
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:31
‪TYPO3\CMS\Dashboard\Widgets
Definition: AdditionalCssInterface.php:18