Issues (186)

Classes/ViewHelpers/Slot/SlotViewHelper.php (1 issue)

Labels
Severity
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * Copyright (C)
6
 * Nathan Boiron <[email protected]>
7
 * Romain Canon <[email protected]>
8
 *
9
 * This file is part of the TYPO3 NotiZ project.
10
 * It is free software; you can redistribute it and/or modify it
11
 * under the terms of the GNU General Public License, either
12
 * version 3 of the License, or any later version.
13
 *
14
 * For the full copyright and license information, see:
15
 * http://www.gnu.org/licenses/gpl-3.0.html
16
 */
17
18
namespace CuyZ\Notiz\ViewHelpers\Slot;
19
20
use CuyZ\Notiz\View\Slot\Application\Slot;
21
use CuyZ\Notiz\View\Slot\SlotContainer;
22
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
0 ignored issues
show
The type TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

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