1 | <?php |
||
24 | class FormObjectProxy |
||
25 | { |
||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $name; |
||
30 | |||
31 | /** |
||
32 | * @var FormObject |
||
33 | */ |
||
34 | protected $formObject; |
||
35 | |||
36 | /** |
||
37 | * @var FormInterface |
||
38 | */ |
||
39 | protected $form; |
||
40 | |||
41 | /** |
||
42 | * @var FormObjectRequestData |
||
43 | */ |
||
44 | protected $requestData; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $formHash; |
||
50 | |||
51 | /** |
||
52 | * @var bool |
||
53 | */ |
||
54 | protected $formWasSubmitted = false; |
||
55 | |||
56 | /** |
||
57 | * @var FormResult |
||
58 | */ |
||
59 | protected $formResult; |
||
60 | |||
61 | /** |
||
62 | * @var FormObjectMetadata |
||
63 | */ |
||
64 | protected $metadata; |
||
65 | |||
66 | /** |
||
67 | * @param FormObject $formObject |
||
68 | * @param FormInterface $form |
||
69 | */ |
||
70 | public function __construct(FormObject $formObject, FormInterface $form) |
||
71 | { |
||
72 | $this->formObject = $formObject; |
||
73 | $this->form = $form; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * @todo |
||
78 | */ |
||
79 | public function initializeObject() |
||
80 | { |
||
81 | $this->metadata = Core::instantiate(FormObjectMetadata::class, $this->formObject); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @return FormObjectRequestData |
||
86 | */ |
||
87 | public function getRequestData() |
||
88 | { |
||
89 | return $this->requestData; |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * @return FormInterface |
||
94 | */ |
||
95 | public function getForm() |
||
96 | { |
||
97 | return $this->form; |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * Will mark the form as submitted (change the result returned by the |
||
102 | * function `formWasSubmitted()`). |
||
103 | */ |
||
104 | public function markFormAsSubmitted() |
||
105 | { |
||
106 | $this->formWasSubmitted = true; |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * Returns `true` if the form was submitted by the user. |
||
111 | * |
||
112 | * @return bool |
||
113 | */ |
||
114 | public function formWasSubmitted() |
||
115 | { |
||
116 | return $this->formWasSubmitted; |
||
117 | } |
||
118 | |||
119 | /** |
||
120 | * @return FormResult |
||
121 | */ |
||
122 | public function getFormResult() |
||
123 | { |
||
124 | // @todo check has |
||
125 | |||
126 | return $this->formResult; |
||
127 | } |
||
128 | |||
129 | /** |
||
130 | * @return bool |
||
131 | */ |
||
132 | public function hasFormResult() |
||
133 | { |
||
134 | return null !== $this->formResult; |
||
135 | } |
||
136 | |||
137 | /** |
||
138 | * @param FormResult $formResult |
||
139 | */ |
||
140 | public function setFormResult(FormResult $formResult) |
||
141 | { |
||
142 | $this->formResult = $formResult; |
||
143 | } |
||
144 | |||
145 | /** |
||
146 | * @return FormMetadata |
||
147 | */ |
||
148 | public function getFormMetadata() |
||
149 | { |
||
150 | return $this->metadata->getMetadata(); |
||
151 | } |
||
152 | |||
153 | /** |
||
154 | * @return string |
||
155 | */ |
||
156 | public function getFormHash() |
||
164 | |||
165 | /** |
||
166 | * @param string $hash |
||
167 | */ |
||
168 | public function setFormHash($hash) |
||
169 | { |
||
170 | $this->formHash = $hash; |
||
171 | } |
||
172 | |||
173 | /** |
||
174 | * @param FormObjectRequestData $requestData |
||
175 | */ |
||
176 | public function injectRequestData(FormObjectRequestData $requestData) |
||
180 | } |
||
181 |