Passed
Push — master ( 46678d...7005ba )
by
unknown
16:43
created

DocHeaderComponent::disable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the TYPO3 CMS project.
5
 *
6
 * It is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License, either version 2
8
 * of the License, or any later version.
9
 *
10
 * For the full copyright and license information, please read the
11
 * LICENSE.txt file that was distributed with this source code.
12
 *
13
 * The TYPO3 project - inspiring people to share!
14
 */
15
16
namespace TYPO3\CMS\Backend\Template\Components;
17
18
use TYPO3\CMS\Core\Resource\ResourceInterface;
19
use TYPO3\CMS\Core\Utility\GeneralUtility;
20
21
/**
22
 * DocHeader component class
23
 */
24
class DocHeaderComponent
25
{
26
    /**
27
     * MenuRegistry Object
28
     *
29
     * @var MenuRegistry
30
     */
31
    protected $menuRegistry;
32
33
    /**
34
     * Meta information
35
     *
36
     * @var MetaInformation
37
     */
38
    protected $metaInformation;
39
40
    /**
41
     * Registry Container for Buttons
42
     *
43
     * @var ButtonBar
44
     */
45
    protected $buttonBar;
46
47
    /**
48
     * @var bool
49
     */
50
    protected $enabled = true;
51
52
    /**
53
     * Sets up buttonBar and MenuRegistry
54
     */
55
    public function __construct()
56
    {
57
        $this->buttonBar = GeneralUtility::makeInstance(ButtonBar::class);
58
        $this->menuRegistry = GeneralUtility::makeInstance(MenuRegistry::class);
59
        $this->metaInformation = GeneralUtility::makeInstance(MetaInformation::class);
60
    }
61
62
    /**
63
     * Set page information
64
     *
65
     * @param array $metaInformation Record array
66
     */
67
    public function setMetaInformation(array $metaInformation)
68
    {
69
        $this->metaInformation->setRecordArray($metaInformation);
70
    }
71
72
    public function setMetaInformationForResource(ResourceInterface $resource): void
73
    {
74
        $this->metaInformation->setResource($resource);
75
    }
76
77
    /**
78
     * Get moduleMenuRegistry
79
     *
80
     * @return MenuRegistry
81
     */
82
    public function getMenuRegistry()
83
    {
84
        return $this->menuRegistry;
85
    }
86
87
    /**
88
     * Get ButtonBar
89
     *
90
     * @return ButtonBar
91
     */
92
    public function getButtonBar()
93
    {
94
        return $this->buttonBar;
95
    }
96
97
    /**
98
     * Determines whether this components is enabled.
99
     *
100
     * @return bool
101
     */
102
    public function isEnabled()
103
    {
104
        return $this->enabled;
105
    }
106
107
    /**
108
     * Sets the enabled property to TRUE.
109
     */
110
    public function enable()
111
    {
112
        $this->enabled = true;
113
    }
114
115
    /**
116
     * Sets the enabled property to FALSE (disabled).
117
     */
118
    public function disable()
119
    {
120
        $this->enabled = false;
121
    }
122
123
    /**
124
     * Returns the abstract content of the docHeader as an array
125
     *
126
     * @return array
127
     */
128
    public function docHeaderContent()
129
    {
130
        return [
131
            'enabled' => $this->isEnabled(),
132
            'buttons' => $this->buttonBar->getButtons(),
133
            'menus' => $this->menuRegistry->getMenus(),
134
            'metaInformation' => $this->metaInformation
135
        ];
136
    }
137
}
138