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\Form\Step; |
15
|
|
|
|
16
|
|
|
use Romm\Formz\Configuration\AbstractFormzConfiguration; |
17
|
|
|
use Romm\Formz\Configuration\Form\Step\Step\StepItem; |
18
|
|
|
use Romm\Formz\Exceptions\EntryNotFoundException; |
19
|
|
|
|
20
|
|
|
class Step extends AbstractFormzConfiguration |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var \Romm\Formz\Configuration\Form\Step\Settings |
24
|
|
|
* @validate NotEmpty |
25
|
|
|
*/ |
26
|
|
|
protected $settings; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var \Romm\Formz\Configuration\Form\Step\Step\StepItem[] |
30
|
|
|
* @validate NotEmpty |
31
|
|
|
*/ |
32
|
|
|
protected $steps; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return Settings |
36
|
|
|
*/ |
37
|
|
|
public function getSettings() |
38
|
|
|
{ |
39
|
|
|
return $this->settings; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return bool |
44
|
|
|
*/ |
45
|
|
|
public function hasSteps() |
46
|
|
|
{ |
47
|
|
|
return null !== $this->steps; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return StepItem[] |
52
|
|
|
*/ |
53
|
|
|
public function getSteps() |
54
|
|
|
{ |
55
|
|
|
return $this->steps; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param string $name |
60
|
|
|
* @return StepItem |
61
|
|
|
* @throws EntryNotFoundException |
62
|
|
|
*/ |
63
|
|
|
public function getStep($name) |
64
|
|
|
{ |
65
|
|
|
if (false === $this->hasStep($name)) { |
66
|
|
|
throw EntryNotFoundException::stepItemNotFound($name); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
return $this->steps[$name]; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param string $name |
74
|
|
|
* @return bool |
75
|
|
|
*/ |
76
|
|
|
public function hasStep($name) |
77
|
|
|
{ |
78
|
|
|
return isset($this->steps[$name]); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return StepItem |
83
|
|
|
*/ |
84
|
|
|
public function getDefaultStep() |
85
|
|
|
{ |
86
|
|
|
return $this->getStep($this->settings->getDefaultStep()); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|