12
12
use Nette ;
13
13
use Nette \DI \Helpers ;
14
14
use Nette \DI \ServiceCreationException ;
15
+ use Nette \PhpGenerator as Php ;
15
16
use Nette \Utils \Reflection ;
16
17
use Nette \Utils \Type ;
17
18
@@ -206,6 +207,10 @@ public function complete(Nette\DI\Resolver $resolver): void
206
207
if (!$ this ->parameters ) {
207
208
$ this ->completeParameters ($ resolver );
208
209
}
210
+ $ this ->convertArguments ($ resultDef ->getFactory ()->arguments );
211
+ foreach ($ resultDef ->getSetup () as $ setup ) {
212
+ $ this ->convertArguments ($ setup ->arguments );
213
+ }
209
214
210
215
if ($ resultDef ->getEntity () instanceof Reference && !$ resultDef ->getFactory ()->arguments ) {
211
216
$ resultDef ->setFactory ([ // render as $container->createMethod()
@@ -247,7 +252,7 @@ private function completeParameters(Nette\DI\Resolver $resolver): void
247
252
$ class
248
253
));
249
254
}
250
- $ this ->resultDefinition ->getFactory ()->arguments [$ ctorParam ->getPosition ()] = Nette \ DI \ContainerBuilder:: literal ('$ ' . $ ctorParam ->name );
255
+ $ this ->resultDefinition ->getFactory ()->arguments [$ ctorParam ->getPosition ()] = new Php \ Literal ('$ ' . $ ctorParam ->name );
251
256
252
257
} elseif (!$ this ->resultDefinition ->getSetup ()) {
253
258
$ hint = Nette \Utils \Helpers::getSuggestion (array_keys ($ ctorParams ), $ param ->name );
@@ -268,9 +273,19 @@ private function completeParameters(Nette\DI\Resolver $resolver): void
268
273
}
269
274
270
275
271
- public function generateMethod (Nette \PhpGenerator \Method $ method , Nette \DI \PhpGenerator $ generator ): void
276
+ public function convertArguments (array &$ args ): void
277
+ {
278
+ foreach ($ args as &$ v ) {
279
+ if (is_string ($ v ) && $ v [0 ] === '$ ' ) {
280
+ $ v = new Php \Literal ($ v );
281
+ }
282
+ }
283
+ }
284
+
285
+
286
+ public function generateMethod (Php \Method $ method , Nette \DI \PhpGenerator $ generator ): void
272
287
{
273
- $ class = (new Nette \ PhpGenerator \ClassType )
288
+ $ class = (new Php \ClassType )
274
289
->addImplement ($ this ->getType ());
275
290
276
291
$ class ->addProperty ('container ' )
0 commit comments