-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
FormState.php
95 lines (84 loc) · 2.07 KB
/
FormState.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace Neos\Form\Core\Runtime;
/*
* This file is part of the Neos.Form package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
use Neos\Utility\Arrays;
/**
* The current state of the form which is attached to the {@link FormRuntime}
* and saved in a session or the client.
*
* **This class is not meant to be subclassed by developers.**
*
* @internal
*/
class FormState
{
/**
* Constant which means that we are currently not on any page; i.e. the form
* has never rendered before.
*/
const NOPAGE = -1;
/**
* The last displayed page index
*
* @var integer
*/
protected $lastDisplayedPageIndex = self::NOPAGE;
/**
* @var array
*/
protected $formValues = [];
/**
* @return boolean FALSE if the form has never been submitted before, TRUE otherwise
*/
public function isFormSubmitted()
{
return ($this->lastDisplayedPageIndex !== self::NOPAGE);
}
/**
* @return integer
*/
public function getLastDisplayedPageIndex()
{
return $this->lastDisplayedPageIndex;
}
/**
* @param integer $lastDisplayedPageIndex
* @return void
*/
public function setLastDisplayedPageIndex($lastDisplayedPageIndex)
{
$this->lastDisplayedPageIndex = $lastDisplayedPageIndex;
}
/**
* @return array
*/
public function getFormValues()
{
return $this->formValues;
}
/**
* @param string $propertyPath
* @param mixed $value
* @return void
*/
public function setFormValue($propertyPath, $value)
{
$this->formValues = Arrays::setValueByPath($this->formValues, $propertyPath, $value);
}
/**
* @param string $propertyPath
* @return mixed
*/
public function getFormValue($propertyPath)
{
return Arrays::getValueByPath($this->formValues, $propertyPath);
}
}