1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* Copyright (C) 2017 |
5
|
|
|
* Nathan Boiron <[email protected]> |
6
|
|
|
* Romain Canon <[email protected]> |
7
|
|
|
* |
8
|
|
|
* This file is part of the TYPO3 NotiZ project. |
9
|
|
|
* It is free software; you can redistribute it and/or modify it |
10
|
|
|
* under the terms of the GNU General Public License, either |
11
|
|
|
* version 3 of the License, or any later version. |
12
|
|
|
* |
13
|
|
|
* For the full copyright and license information, see: |
14
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
15
|
|
|
*/ |
16
|
|
|
|
17
|
|
|
namespace CuyZ\Notiz\View\Slot; |
18
|
|
|
|
19
|
|
|
use CuyZ\Notiz\Definition\DefinitionService; |
20
|
|
|
use CuyZ\Notiz\Definition\Tree\EventGroup\Event\EventDefinition; |
21
|
|
|
use CuyZ\Notiz\ViewHelpers\Slot\RenderViewHelper; |
22
|
|
|
use CuyZ\Notiz\ViewHelpers\Slot\SlotViewHelper; |
23
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
24
|
|
|
use TYPO3\CMS\Core\Utility\VersionNumberUtility; |
25
|
|
|
use TYPO3\CMS\Fluid\View\StandaloneView; |
26
|
|
|
|
27
|
|
|
class SlotView extends StandaloneView |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @var SlotContainer |
31
|
|
|
*/ |
32
|
|
|
protected $slots; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var EventDefinition |
36
|
|
|
*/ |
37
|
|
|
protected $eventDefinition; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param EventDefinition $eventDefinition |
41
|
|
|
*/ |
42
|
|
|
public function __construct(EventDefinition $eventDefinition) |
43
|
|
|
{ |
44
|
|
|
parent::__construct(); |
45
|
|
|
|
46
|
|
|
$this->eventDefinition = $eventDefinition; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Will render the section `Slots` of the view. This will allow collecting |
51
|
|
|
* all the slots for the event, that are then returned. |
52
|
|
|
* |
53
|
|
|
* @return SlotContainer |
54
|
|
|
*/ |
55
|
|
|
public function getSlots() |
56
|
|
|
{ |
57
|
|
|
if (!$this->slots) { |
58
|
|
|
$this->slots = GeneralUtility::makeInstance(SlotContainer::class); |
59
|
|
|
|
60
|
|
|
$this->baseRenderingContext |
61
|
|
|
->getViewHelperVariableContainer() |
62
|
|
|
->add(SlotViewHelper::class, SlotViewHelper::SLOT_CONTAINER, $this->slots); |
63
|
|
|
|
64
|
|
|
$variables = [ |
65
|
|
|
'event' => $this->eventDefinition, |
66
|
|
|
'definition' => DefinitionService::get()->getDefinition(), |
67
|
|
|
]; |
68
|
|
|
|
69
|
|
|
if (version_compare(VersionNumberUtility::getCurrentTypo3Version(), '8.0.0', '>=')) { |
70
|
|
|
$this->renderSection('Slots', $variables, true); |
71
|
|
|
} else { |
72
|
|
|
/** |
73
|
|
|
* @deprecated Must be removed when TYPO3 v7 is not supported anymore. |
74
|
|
|
*/ |
75
|
|
|
$parsedTemplate = $this->templateParser->parse($this->getTemplateSource()); |
76
|
|
|
|
77
|
|
|
$this->startRendering(self::RENDERING_TEMPLATE, $parsedTemplate, $this->baseRenderingContext); |
78
|
|
|
$this->renderSection('Slots', $variables, true); |
79
|
|
|
$this->stopRendering(); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return $this->slots; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param array $slotsValues |
88
|
|
|
* @param array $markers |
89
|
|
|
* @return string |
90
|
|
|
*/ |
91
|
|
|
public function renderWithSlots(array $slotsValues, array $markers) |
92
|
|
|
{ |
93
|
|
|
$viewHelperVariableContainer = $this->baseRenderingContext->getViewHelperVariableContainer(); |
94
|
|
|
|
95
|
|
|
$viewHelperVariableContainer->add(RenderViewHelper::class, RenderViewHelper::SLOT_CONTAINER, $this->getSlots()); |
96
|
|
|
$viewHelperVariableContainer->add(RenderViewHelper::class, RenderViewHelper::SLOT_VALUES, $slotsValues); |
97
|
|
|
$viewHelperVariableContainer->add(RenderViewHelper::class, RenderViewHelper::MARKERS, $markers); |
98
|
|
|
|
99
|
|
|
return $this->render(); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return EventDefinition |
104
|
|
|
*/ |
105
|
|
|
public function getEventDefinition() |
106
|
|
|
{ |
107
|
|
|
return $this->eventDefinition; |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|