|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* 2017 Romain CANON <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* This file is part of the TYPO3 FormZ project. |
|
6
|
|
|
* It is free software; you can redistribute it and/or modify it |
|
7
|
|
|
* under the terms of the GNU General Public License, either |
|
8
|
|
|
* version 3 of the License, or any later version. |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, see: |
|
11
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Romm\Formz\Configuration\View\Layouts; |
|
15
|
|
|
|
|
16
|
|
|
use Romm\ConfigurationObject\Traits\ConfigurationObject\StoreArrayIndexTrait; |
|
17
|
|
|
use Romm\Formz\Configuration\AbstractFormzConfiguration; |
|
18
|
|
|
use Romm\Formz\Exceptions\EntryNotFoundException; |
|
19
|
|
|
|
|
20
|
|
|
class LayoutGroup extends AbstractFormzConfiguration |
|
21
|
|
|
{ |
|
22
|
|
|
use StoreArrayIndexTrait; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var \Romm\Formz\Configuration\View\Layouts\Layout[] |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $items = []; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var string |
|
31
|
|
|
* @validate NotEmpty |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $templateFile; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @return string |
|
37
|
|
|
*/ |
|
38
|
|
|
public function getName() |
|
39
|
|
|
{ |
|
40
|
|
|
return $this->getArrayIndex(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @return Layout[] |
|
45
|
|
|
*/ |
|
46
|
|
|
public function getItems() |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->items; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @param string $name |
|
53
|
|
|
* @return bool |
|
54
|
|
|
*/ |
|
55
|
|
|
public function hasItem($name) |
|
56
|
|
|
{ |
|
57
|
|
|
return true === isset($this->items[$name]); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @param string $name |
|
62
|
|
|
* @return Layout |
|
63
|
|
|
* @throws EntryNotFoundException |
|
64
|
|
|
*/ |
|
65
|
|
|
public function getItem($name) |
|
66
|
|
|
{ |
|
67
|
|
|
if (false === $this->hasItem($name)) { |
|
68
|
|
|
throw EntryNotFoundException::viewLayoutItemNotFound($name); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
return $this->items[$name]; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param string $name |
|
76
|
|
|
* @param Layout $layout |
|
77
|
|
|
*/ |
|
78
|
|
|
public function addItem($name, Layout $layout) |
|
79
|
|
|
{ |
|
80
|
|
|
$layout->setParents([$this]); |
|
81
|
|
|
|
|
82
|
|
|
$this->items[$name] = $layout; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @return string |
|
87
|
|
|
*/ |
|
88
|
|
|
public function getTemplateFile() |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->templateFile; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @param string $templateFile |
|
95
|
|
|
*/ |
|
96
|
|
|
public function setTemplateFile($templateFile) |
|
97
|
|
|
{ |
|
98
|
|
|
$this->templateFile = $templateFile; |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|