@@ -144,40 +144,10 @@ public function loadState(array $params): void
144144
145145 /**
146146 * Saves state informations for next request.
147- * @param ComponentReflection $reflection (internal, used by Presenter)
148147 */
149- public function saveState (array &$ params, ComponentReflection $ reflection = null ): void
148+ public function saveState (array &$ params ): void
150149 {
151- $ reflection = $ reflection === null ? $ this ->getReflection () : $ reflection ;
152- foreach ($ reflection ->getPersistentParams () as $ name => $ meta ) {
153- if (isset ($ params [$ name ])) {
154- // injected value
155-
156- } elseif (array_key_exists ($ name , $ params )) { // nulls are skipped
157- continue ;
158-
159- } elseif ((!isset ($ meta ['since ' ]) || $ this instanceof $ meta ['since ' ]) && isset ($ this ->$ name )) {
160- $ params [$ name ] = $ this ->$ name ; // object property value
161-
162- } else {
163- continue ; // ignored parameter
164- }
165-
166- $ type = gettype ($ meta ['def ' ]);
167- if (!ComponentReflection::convertType ($ params [$ name ], $ type )) {
168- throw new InvalidLinkException (sprintf (
169- "Value passed to persistent parameter '%s' in %s must be %s, %s given. " ,
170- $ name ,
171- $ this instanceof Presenter ? 'presenter ' . $ this ->getName () : "component ' {$ this ->getUniqueId ()}' " ,
172- $ type === 'NULL ' ? 'scalar ' : $ type ,
173- is_object ($ params [$ name ]) ? get_class ($ params [$ name ]) : gettype ($ params [$ name ])
174- ));
175- }
176-
177- if ($ params [$ name ] === $ meta ['def ' ] || ($ meta ['def ' ] === null && $ params [$ name ] === '' )) {
178- $ params [$ name ] = null ; // value transmit is unnecessary
179- }
180- }
150+ $ this ->getReflection ()->saveState ($ this , $ params );
181151 }
182152
183153
0 commit comments