|
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\ViewHelpers\Slot; |
|
18
|
|
|
|
|
19
|
|
|
use CuyZ\Notiz\View\Slot\Application\Slot; |
|
20
|
|
|
use CuyZ\Notiz\View\Slot\SlotContainer; |
|
21
|
|
|
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; |
|
22
|
|
|
|
|
23
|
|
|
abstract class SlotViewHelper extends AbstractViewHelper |
|
24
|
|
|
{ |
|
25
|
|
|
const SLOT_CONTAINER = 'SlotContainer'; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @inheritdoc |
|
29
|
|
|
*/ |
|
30
|
|
|
public function initializeArguments() |
|
31
|
|
|
{ |
|
32
|
|
|
$this->registerArgument('name', 'string', 'Name of the slot, must be unique.', true); |
|
33
|
|
|
$this->registerArgument('label', 'string', 'Label of the slot, can use LLL references.'); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @inheritdoc |
|
38
|
|
|
*/ |
|
39
|
|
|
public function render() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->getSlotContainer()->add($this->getSlot()); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @return Slot |
|
46
|
|
|
*/ |
|
47
|
|
|
abstract protected function getSlot(); |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @return string |
|
51
|
|
|
*/ |
|
52
|
|
|
protected function getSlotName() |
|
53
|
|
|
{ |
|
54
|
|
|
return $this->arguments['name']; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @return string |
|
59
|
|
|
*/ |
|
60
|
|
|
protected function getSlotLabel() |
|
61
|
|
|
{ |
|
62
|
|
|
$label = $this->arguments['label']; |
|
63
|
|
|
|
|
64
|
|
|
if (!$label) { |
|
65
|
|
|
$label = $this->renderChildren(); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
return $label; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @return SlotContainer |
|
73
|
|
|
*/ |
|
74
|
|
|
protected function getSlotContainer() |
|
75
|
|
|
{ |
|
76
|
|
|
return $this->viewHelperVariableContainer->get(__CLASS__, self::SLOT_CONTAINER); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|