-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathParserData.php
113 lines (96 loc) · 1.86 KB
/
ParserData.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
namespace Gregwar\Formidable;
use Gregwar\Formidable\Fields\Field;
use Gregwar\Formidable\Fields\RadioField;
class ParserData
{
/**
* Objects in the form
*/
protected $data = array();
/**
* Sources
*/
protected $sources = array();
/**
* Fields
*/
protected $fields = array();
/**
* Does we need js?
*/
protected $needJs = false;
/**
* Placeholders
*/
protected $placeholders = array();
/**
* Form header
*/
protected $head = null;
public function __sleep()
{
return array('data', 'sources', 'fields', 'needJs', 'head', 'placeholders');
}
/**
* Form components
*/
public function getData()
{
return $this->data;
}
/**
* Fields mapped by name
*/
public function getFields()
{
return $this->fields;
}
/**
* Sources
*/
public function getSources()
{
return $this->sources;
}
/**
* CSRF token
*/
public function getToken()
{
return $this->token;
}
/**
* Gets the head
*/
public function getHead()
{
return $this->head;
}
/**
* Does we need js?
*/
public function needJs()
{
return $this->needJs;
}
/**
* Gets a field
*/
public function getField($name)
{
if (isset($this->fields[$name])) {
return $this->fields[$name];
} else {
throw new \InvalidArgumentException('Field with name '.$name.' not found');
}
}
public function getPlaceholders($name)
{
if (isset($this->placeholders[$name])) {
return $this->placeholders[$name];
} else {
throw new \InvalidArgumentException('Placeholder with name '.$name.' not found');
}
}
}