@@ -91,7 +91,7 @@ public static function createChoiceLabel($choice)
9191 {
9292 return (string ) $ choice ;
9393 }
94-
94+
9595 /**
9696 * Creates the field name for a choice.
9797 *
@@ -134,17 +134,17 @@ public function configureOptions(OptionsResolver $resolver)
134134 $ choiceLoader = function (Options $ options ) {
135135 // Unless the choices are given explicitly, load them on demand
136136 if (null === $ options ['choices ' ]) {
137-
137+
138138 $ propelChoiceLoader = new PropelChoiceLoader (
139139 $ this ->choiceListFactory ,
140140 $ options ['class ' ],
141141 $ options ['query ' ],
142142 $ options ['index_property ' ]
143143 );
144-
144+
145145 return $ propelChoiceLoader ;
146146 }
147-
147+
148148 return null ;
149149 };
150150
@@ -178,12 +178,15 @@ public function configureOptions(OptionsResolver $resolver)
178178 $ firstIdentifier = current ($ identifier );
179179 if (count ($ identifier ) === 1 && in_array ($ firstIdentifier ->getPdoType (), [\PDO ::PARAM_BOOL , \PDO ::PARAM_INT , \PDO ::PARAM_STR ])) {
180180 return function ($ object ) use ($ firstIdentifier ) {
181- return call_user_func ([$ object , 'get ' . ucfirst ($ firstIdentifier ->getPhpName ())]);
181+ if ($ object ) {
182+ return call_user_func ([$ object , 'get ' . ucfirst ($ firstIdentifier ->getPhpName ())]);
183+ }
184+ return null ;
182185 };
183186 }
184187 return null ;
185188 };
186-
189+
187190 $ queryNormalizer = function (Options $ options , $ query ) {
188191 if ($ query === null ) {
189192 $ queryClass = $ options ['class ' ] . 'Query ' ;
@@ -202,7 +205,7 @@ public function configureOptions(OptionsResolver $resolver)
202205 }
203206 return $ query ;
204207 };
205-
208+
206209 $ choiceLabelNormalizer = function (Options $ options , $ choiceLabel ) {
207210 if ($ choiceLabel === null ) {
208211 if ($ options ['property ' ] == null ) {
@@ -212,16 +215,16 @@ public function configureOptions(OptionsResolver $resolver)
212215 /** @var ModelCriteria $query */
213216 $ query = $ options ['query ' ];
214217 $ getter = 'get ' . ucfirst ($ query ->getTableMap ()->getColumn ($ valueProperty )->getPhpName ());
215-
218+
216219 $ choiceLabel = function ($ choice ) use ($ getter ) {
217220 return call_user_func ([$ choice , $ getter ]);
218221 };
219222 }
220223 }
221-
224+
222225 return $ choiceLabel ;
223226 };
224-
227+
225228 $ resolver ->setDefaults ([
226229 'query ' => null ,
227230 'index_property ' => null ,
0 commit comments