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
|
|
|
|
18
|
|
|
namespace TYPO3\CMS\Dashboard\Widgets; |
19
|
|
|
|
20
|
|
|
use TYPO3\CMS\Fluid\View\StandaloneView; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Concrete CTA button implementation |
24
|
|
|
* |
25
|
|
|
* Shows a widget with a CTA button to easily go to a specific page or do a specific action. You can add a button to the |
26
|
|
|
* widget by defining a button provider. |
27
|
|
|
* |
28
|
|
|
* The following options are available during registration: |
29
|
|
|
* - text string Adds a text to the widget to give some more background information about |
30
|
|
|
* what a user can expect when clicking the button. You can either enter a |
31
|
|
|
* normal string or a translation string (eg. LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.documentation.gettingStarted.text) |
32
|
|
|
* @see ButtonProviderInterface |
33
|
|
|
*/ |
34
|
|
|
class CtaWidget implements WidgetInterface |
35
|
|
|
{ |
36
|
|
|
/** |
37
|
|
|
* @var WidgetConfigurationInterface |
38
|
|
|
*/ |
39
|
|
|
private $configuration; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @var StandaloneView |
43
|
|
|
*/ |
44
|
|
|
private $view; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @var array |
48
|
|
|
*/ |
49
|
|
|
private $options; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @var ButtonProviderInterface|null |
53
|
|
|
*/ |
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
|
|
|
} |
80
|
|
|
|